Class AHURootedTreeIsomorphismInspector<V,E>
- Type Parameters:
V- the type of the verticesE- the type of the edges
- All Implemented Interfaces:
IsomorphismInspector<V,E>
The original algorithm was first presented in "Alfred V. Aho and John E. Hopcroft. 1974. The Design and Analysis of Computer Algorithms (1st ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA."
This implementation runs in linear time (in the number of vertices of the input trees) while using a linear amount of memory.
Note: If the input graph is directed, it effectively considers only the subtree reachable from the specified root.
For an implementation that supports unrooted trees see
AHUUnrootedTreeIsomorphismInspector.
For an implementation that supports rooted forests see AHUForestIsomorphismInspector.
Note: This inspector only returns a single mapping (chosen arbitrarily) rather than all possible mappings.
- Author:
- Alexandru Valeanu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet an isomorphism between the input trees ornullif none exists.Get an iterator over all calculated (isomorphic) mappings between two graphs.booleanCheck if an isomorphism exists.
-
Constructor Details
-
AHURootedTreeIsomorphismInspector
Construct a new AHU rooted tree isomorphism inspector. Note: The constructor does NOT check if the input trees are valid.- Parameters:
tree1- the first rooted treeroot1- the root of the first treetree2- the second rooted treeroot2- the root of the second tree- Throws:
NullPointerException- iftree1ortree2isnullNullPointerException- ifroot1orroot2isnullIllegalArgumentException- iftree1ortree2is emptyIllegalArgumentException- ifroot1orroot2is an invalid vertex
-
-
Method Details
-
getMappings
Get an iterator over all calculated (isomorphic) mappings between two graphs.- Specified by:
getMappingsin interfaceIsomorphismInspector<V,E> - Returns:
- an iterator over all calculated (isomorphic) mappings between two graphs
-
isomorphismExists
public boolean isomorphismExists()Check if an isomorphism exists.- Specified by:
isomorphismExistsin interfaceIsomorphismInspector<V,E> - Returns:
- true if there is an isomorphism, false if there is no isomorphism
-
getMapping
Get an isomorphism between the input trees ornullif none exists.- Returns:
- isomorphic mapping,
nullis none exists
-