Cluster

detroit.cluster() Cluster

Builds a new cluster layout with default settings.

Returns:

Cluster object

Return type:

Cluster

class detroit.hierarchy.cluster.Cluster

Cluster layout

__call__(root: Node) Node

Lays out the specified root hierarchy, assigning the following properties on root and its descendants:

  • node.x - the x-coordinate of the node

  • node.y - the y coordinate of the node

The coordinates x and y represent an arbitrary coordinate system; for example, you can treat x as an angle and y as a radius to produce a radial layout. You may want to call root.sort before passing the hierarchy to the cluster layout.

Parameters:

root (Node) – Root node

Returns:

Node organized as cluster

Return type:

Node

set_separation(separation: Callable[[Node, Node], int]) Cluster

Sets the separation accessor to the specified function and returns this cluster layout.

Parameters:

separation (Callable[[Node, Node], int]) – Separation function which compares two nodes.

Returns:

Itself

Return type:

Cluster

set_size(size: tuple[float, float]) Cluster

Sets this cluster layout’s size to the specified two-element array of numbers [width, height] and returns this cluster layout. A layout size of None indicates that a node size will be used instead. The coordinates x and y represent an arbitrary coordinate system; for example, to produce a radial layout, a size of [360, radius] corresponds to a breadth of 360° and a depth of radius.

Parameters:

size (tuple[float, float]) – Size values

Returns:

Itself

Return type:

Cluster

set_node_size(size: tuple[float, float]) Cluster

Sets this cluster layout’s node size to the specified two-element array of numbers [width, height] and returns this cluster layout. A node size of null indicates that a layout size will be used instead. When a size is specified, the root node is always positioned at \((0, 0)\).

Parameters:

size (tuple[float, float]) – Size values

Returns:

Itself

Return type:

Cluster