Package org.graph4j.isomorphism
Class OrderedDigraph
java.lang.Object
org.graph4j.isomorphism.OrderedDigraph
Class that orders the vertices of a digraph according to their degree.
Also, this class caches(if wanted) the predecessors, successors, and edges of the vertices, for a faster access.
- Author:
- Ignat Gabriel-Andrei
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOrderedDigraph(Digraph dg, boolean cache) Constructor that orders the vertices of the given digraph according to their degree. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsEdge(int vertexIndex1, int vertexIndex2) Checks if there is an edge between the two vertices.getEdge(int vertexIndex1, int vertexIndex2) getGraph()intintgetVertexNumber(int vertexIndex) Return the vertex number of the vertex at the given position in the order.intgetVertexOrder(int vertexNumber) intindegree(int vertexIndex) intoutdegree(int vertexIndex) int[]predecessors(int vertexIndex) int[]successors(int vertexIndex)
-
Field Details
-
dg
-
n
protected final int n
-
-
Constructor Details
-
OrderedDigraph
Constructor that orders the vertices of the given digraph according to their degree.- Parameters:
dg- the digraph to be ordered and possibly cachedcache- if true, the algorithm will cache the predecessors, successors, the adjacency relations
-
OrderedDigraph
-
-
Method Details
-
getGraph
- Returns:
- the digraph
-
getNumVertices
public int getNumVertices()- Returns:
- the number of vertices in the digraph
-
getVertexNumber
public int getVertexNumber(int vertexIndex) Return the vertex number of the vertex at the given position in the order.- Parameters:
vertexIndex- the order in the sorted list of vertices- Returns:
- the vertex number
-
getVertexOrder
public int getVertexOrder(int vertexNumber) - Parameters:
vertexNumber- the vertex number in the digraph- Returns:
- the index of the vertex in the sorted list of vertices
-
getEdge
- Parameters:
vertexIndex1- the index of the source vertex in the sorted list of verticesvertexIndex2- the index of the target vertex in the sorted list of vertices- Returns:
- the corresponding edge
-
predecessors
public int[] predecessors(int vertexIndex) - Parameters:
vertexIndex- the index of the vertex in the sorted list of vertices- Returns:
- the indices in the order of the predecessors of the corresponding vertex number
-
successors
public int[] successors(int vertexIndex) - Parameters:
vertexIndex- the order of the vertex in the sorted list of vertices- Returns:
- the successors of the corresponding vertex number
-
containsEdge
public boolean containsEdge(int vertexIndex1, int vertexIndex2) Checks if there is an edge between the two vertices.- Parameters:
vertexIndex1- the index of the source vertex in the sorted list of verticesvertexIndex2- the index of the target vertex in the sorted list of vertices- Returns:
- true if there is an edge between the two vertices, false otherwise
-
indegree
public int indegree(int vertexIndex) - Parameters:
vertexIndex- the index of the vertex in the sorted list of vertices- Returns:
- the indegree of the vertex
-
outdegree
public int outdegree(int vertexIndex) - Parameters:
vertexIndex- the index of the vertex in the sorted list of vertices- Returns:
- the outdegree of the vertex
-