finesse.tree.TreeNode.from_network

TreeNode.from_network(type cls, network, root)

Create a tree node hierarchy from an acyclic network.

Parameters:
networknetworkx.Graph

The network that is to be represented as a tree.

roothashable

The network node to use as the root of the tree.

Raises:
ValueError

When the specified network is not a forest.

Notes

Cyclic networks are handled by networkx.algorithms.traversal.depth_first_search.dfs_tree(), so this method does not need to detect and avoid such cycles.