Package org.graph4j.isomorphism
Class AbstractUllmanState
java.lang.Object
org.graph4j.isomorphism.AbstractState
org.graph4j.isomorphism.AbstractUllmanState
- All Implemented Interfaces:
State
- Direct Known Subclasses:
UllmanExactState,UllmanSubState
Abstract class for the Ullman's algorithm: exact isomorphism and subgraph isomorphism.
Based on the paper " J.R. Ullmann, An Algorithm for Subgraph Isomorphism, Journal of the Association for Computing Machinery, 1976"
A matrix M is used to store the compatibility between the vertices of the two graphs.
After a pair of vertices is added to the matching, the matrix M is refined, in order to remove the inconsistent pairs, thus reducing the search space.
- Author:
- Ignat Gabriel-Andrei
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected int[][]protected intprotected int -
Constructor Summary
ConstructorsConstructorDescriptionAbstractUllmanState(Digraph g1, Digraph g2) AbstractUllmanState(Digraph g1, Digraph g2, boolean cache) Copy constructor: the arrays are just referenced, for memory efficiency -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPair()Adds the pair (prev_1, prev_2) to the matchingvoidReturn to the previous stateabstract booleanexactOrSubgraphIsomorphismCompatibilityCheck(int v1, int v2) Compatibility function for the 2 cases: exact and subgraph isomorphismprotected booleanexistsCandidateNeighbourInSecondGraph(int i, int j) For every neighbour of i, there must be at least one candidate that is neighbour of j If this condition is not respected, then j is eliminated as a candidate for igetCandidates(int i) abstract booleanisDead()Checks if the current state can be pruned.booleanFeasible pair: vertices are compatibleabstract booleanisGoal()Checks if the current state is complete.booleannextPair()Finds the next pair of vertices to be matched prev_1 must always be equal to core_len(clasic backtracking behaviour) prev_2 will have values that are compatible with prev_1voidAfter a successful addPair(), we must reinitialize prev_1 and prev_2 in order to find the next pairMethods inherited from class org.graph4j.isomorphism.AbstractState
compatibleEdges, compatibleVertices, getCoreLen, getMapping
-
Field Details
-
COMPATIBLE
public static final int COMPATIBLE- See Also:
-
M
protected int[][] M -
prev_1
protected int prev_1 -
prev_2
protected int prev_2
-
-
Constructor Details
-
AbstractUllmanState
- Parameters:
g1- the first graph, with the vertices ordered by degree.g2- the second graph, with the vertices ordered by degree.cache-trueif caching is enabled.
-
AbstractUllmanState
-
AbstractUllmanState
Copy constructor: the arrays are just referenced, for memory efficiency- Parameters:
s- : the state to be copied
-
-
Method Details
-
exactOrSubgraphIsomorphismCompatibilityCheck
public abstract boolean exactOrSubgraphIsomorphismCompatibilityCheck(int v1, int v2) Compatibility function for the 2 cases: exact and subgraph isomorphism- Parameters:
v1- the first vertex.v2- the seconf vertex.- Returns:
trueif they are compatible.
-
nextPair
public boolean nextPair()Finds the next pair of vertices to be matched prev_1 must always be equal to core_len(clasic backtracking behaviour) prev_2 will have values that are compatible with prev_1 -
isFeasiblePair
public boolean isFeasiblePair()Feasible pair: vertices are compatible -
addPair
public void addPair()Adds the pair (prev_1, prev_2) to the matching -
backTrack
public void backTrack()Return to the previous state -
resetPreviousVertices
public void resetPreviousVertices()After a successful addPair(), we must reinitialize prev_1 and prev_2 in order to find the next pair -
isGoal
public abstract boolean isGoal()Checks if the current state is complete. -
isDead
public abstract boolean isDead()Checks if the current state can be pruned. -
existsCandidateNeighbourInSecondGraph
protected boolean existsCandidateNeighbourInSecondGraph(int i, int j) For every neighbour of i, there must be at least one candidate that is neighbour of j If this condition is not respected, then j is eliminated as a candidate for i- Parameters:
i- : node from g1j- : node from g2, some candidate for i- Returns:
- true if the condition is respected, false otherwise
-
getCandidates
-