Package org.graph4j.isomorphism
Class RootedForestIsomorphism
java.lang.Object
org.graph4j.isomorphism.RootedForestIsomorphism
- All Implemented Interfaces:
IsomorphismAlgorithm
Algorithm for testing isomorphism of forests with specified roots.
This algorithm is based on "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.", page 83-84.
Time complexity: linear in the number of vertices of the input trees. Space complexity: linear in the number of vertices of the input trees.
- Author:
- Ignat Gabriel-Andrei, Cristian Frasinaru
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRootedForestIsomorphism(Graph forest1, Graph forest2, VertexSet roots1, VertexSet roots2) Constructor for the rooted forest isomorphism algorithm. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the graphs are isomorphic.voidFinds the isomorphic mapping between the first and the second graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.graph4j.isomorphism.IsomorphismAlgorithm
checkTrivialConditions
-
Constructor Details
-
RootedForestIsomorphism
Constructor for the rooted forest isomorphism algorithm. It does not verify if the input graphs are actually forests.- Parameters:
forest1- the first forest.forest2- the second forest.roots1- the roots of the first forest.roots2- the roots of the second forest.- Throws:
NullPointerException- if eitherforest1orforest2isnull.IllegalArgumentException- if eitherforest1orforest2is not a simple graph.IllegalArgumentException- if eitherroots1orroots2contain vertices that are not in the forest.
-
-
Method Details
-
areIsomorphic
public boolean areIsomorphic()Description copied from interface:IsomorphismAlgorithmChecks if the graphs are isomorphic.- Specified by:
areIsomorphicin interfaceIsomorphismAlgorithm- Returns:
trueif the graphs are isomorphic,falseotherwise.
-
findIsomorphism
Description copied from interface:IsomorphismAlgorithmFinds the isomorphic mapping between the first and the second graph.- Specified by:
findIsomorphismin interfaceIsomorphismAlgorithm- Returns:
- the isomorphism or
nullif the graphs are not isomorphic.
-
createRootedTreeAlg
public void createRootedTreeAlg()
-