This documents the development version of NetworkX. Documentation for the current release can be found here.
Given two undirected (or free) trees
t2, this routine will determine if they are isomorphic. 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.
- t1undirected NetworkX graph
One of the trees being compared
- t2undirected NetworkX graph
The other tree being compared
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.
This runs in O(n*log(n)) time for trees with n nodes.