rooted_tree_isomorphism¶
- rooted_tree_isomorphism(t1, root1, t2, root2)[source]¶
Given two rooted trees
t1andt2, with rootsroot1androot2respectivly 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 oft2, 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.
- Parameters
- `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.
- Returns
- isomorphismlist
A list of pairs in which the left element is a node in
t1and the right element is a node int2. 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.If
t1andt2are not isomorphic, then it returns the empty list.