This documents the development version of NetworkX. Documentation for the current release can be found here.
rooted_tree_isomorphism(t1, root1, t2, root2)¶
Given two rooted trees
t2, with roots
root2respectivly this routine will determine if they are isomorphic.
These trees may be either directed or undirected, but if they are directed, all edges should flow from the root.
It returns the isomorphism, a mapping of the nodes of
t1onto the nodes of
t2, such that two trees are then identical.
Note that two trees may have more than one isomorphism, and this routine just returns one valid mapping.
- `t1`NetworkX graph
One of the trees being compared
- `root1`a node of
t1which is the root of the tree
- `t2`undirected NetworkX graph
The other tree being compared
- `root2`a node of
t2which is the root of the tree
- This is a subroutine used to implement `tree_isomorphism`, but will
- be somewhat faster if you already have rooted trees.
A list of pairs in which the left element is a node in
t1and the right element is a node in
t2. The pairs are in arbitrary order. If the nodes in one tree is mapped to the names in the other, then trees will be identical. Note that an isomorphism will not necessarily be unique.
t2are not isomorphic, then it returns the empty list.