Package org.graph4j.ordering
Class TopologicalOrdering
java.lang.Object
org.graph4j.DirectedGraphAlgorithm
org.graph4j.ordering.TopologicalOrdering
Computes an ordering of a directed graph vertices such that for every
directed edge (u,v) from vertex u to vertex v, u comes before v in the
ordering.
A graph is chordal if and only if it has a perfect elimination ordering. For
a chordal graph, LexBFS and Maximum Cardinality Search algorithms produce
reversed perfect elimination orderings.
- Author:
- Cristian Frăsinaru
-
Field Summary
Fields inherited from class org.graph4j.DirectedGraphAlgorithm
graph, stronglyConnected -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]int[]booleanisUnique()Checks if the topological sorting is unique.Methods inherited from class org.graph4j.DirectedGraphAlgorithm
isStronglyConnected
-
Constructor Details
-
TopologicalOrdering
- Parameters:
digraph- the input directed graph.
-
-
Method Details
-
findOrdering
public int[] findOrdering()- Returns:
- the topological order, or
nullif the digraph is not acyclic.
-
isUnique
public boolean isUnique()Checks if the topological sorting is unique. If it is unique, the digraph contains a Hamiltonian path.- Returns:
trueif the topological sorting exists and it is unique.
-
getLevels
public int[] getLevels()- Returns:
- the levels of the DAG.
-