Package org.graph4j.isomorphism
Class ForestIsomorphism
java.lang.Object
org.graph4j.isomorphism.ForestIsomorphism
- All Implemented Interfaces:
IsomorphismAlgorithm
Algorithm for testing isomorphism of undirected forests.
The implementation runs in linear time (in the number of vertices of the
input forest).
- Author:
- Cristian Frasinaru
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionForestIsomorphism(Graph forest1, Graph forest2) Constructor for the forest isomorphism algorithm. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the graphs are isomorphic.Finds 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
-
ForestIsomorphism
Constructor for the forest isomorphism algorithm. It does not verify if the input graphs are actually forests.- Parameters:
forest1- the first forest.forest2- the second forest.- Throws:
NullPointerException- if eitherforest1orforest2isnull.IllegalArgumentException- if eitherforest1orforest2is not undirected.
-
-
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.
-