Package org.graph4j.isomorphism
Class Isomorphism
java.lang.Object
org.graph4j.isomorphism.Isomorphism
An immutable one-to-one correspondence (bijection) between the vertices of two
graphs that preserves the edge connections. Objects of this class are created
by algorithms that find tan isomorphism between two graphs.
- Author:
- Ignat Gabriel-Andrei, Cristian Frasinaru
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIsomorphism(Graph graph1, Graph graph2, int[] mapping, int[] inverse) Creates an isomorphism between two graphs. -
Method Summary
Modifier and TypeMethodDescriptionint[]inverse()Returns a copy of the inverse mapping between the second graph and the first graph.intinverse(int u) Returns the inverse mapping of a vertex number in the second graph.booleanisValid()Checks if the current mapping is a valid isomorphism, i.e. it is a bijection between vertices that preserves the edges.int[]mapping()Returns a copy of the mapping between the first graph and the second graph.intmapping(int v) Returns the mapping of a vertex number in the first graph.toString()
-
Constructor Details
-
Isomorphism
Creates an isomorphism between two graphs. If (@code mapping[i]=v} then the vertex with index i in the first graph is mapped to the vertex with number v in the second graph. If (@code inverse[j]=u} then the vertex with index j in the second graph is mapped to the vertex with number u in the first graph.- Parameters:
graph1- the first graph.graph2- the second graph.mapping- the correspondence between the vertices in the first graph and the second graph.inverse- the correspondence between the vertices in the second graph and the first graph.
-
-
Method Details
-
mapping
public int[] mapping()Returns a copy of the mapping between the first graph and the second graph.- Returns:
- the correspondence between the vertices in the first graph and the second graph.
-
mapping
public int mapping(int v) Returns the mapping of a vertex number in the first graph.- Parameters:
v- a vertex number in the first graph.- Returns:
- the vertex number in the second graph to which v is mapped to.
-
inverse
public int[] inverse()Returns a copy of the inverse mapping between the second graph and the first graph.- Returns:
- the correspondence between the vertices in the second graph and the first graph.
-
inverse
public int inverse(int u) Returns the inverse mapping of a vertex number in the second graph.- Parameters:
u- a vertex number in the second graph.- Returns:
- the vertex number in the first graph to which u is mapped to.
-
isValid
public boolean isValid()Checks if the current mapping is a valid isomorphism, i.e. it is a bijection between vertices that preserves the edges.- Returns:
trueif the current mapping is a valid isomorphism,falseotherwise.
-
toString
-