tst_layout#

BinTreeNetworkX.tst_layout(depths: dict[int, float]) dict[int, tuple[float, float]] | None#

Position the nodes of the tree in the following way:

  • the y-coordinates are determined by depths. Since the y-axis of the coordinate system points up the heights are inverted for the coordinates so that the tree grows towards the bottom.

  • the x coordinates are chosen such that each subtree of a node lies entirely on one side of the node. If a node has two subtrees they must lie on different side. This layout fails if a node has 3 subtrees and in that case the function returns None.

Parameters#

depthsdict

The depths of each node.

Returns#

dict or None

The positions if the layout works. Otherwise None.