Package com.jgalgo.alg
Interface TopologicalOrderAlgo
-
public interface TopologicalOrderAlgoAlgorithm that calculate a topological order of graph vertices.A topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge \((u,v)\), \(u\) comes before \(v\) in the ordering. A topological ordering exist if and only if the graph is directed and acyclic (DAG).
This algorithm compute the topological ordering of a given DAG graph in linear time and space.
Use
newInstance()to get a default implementation of this interface.- Author:
- Barak Ugav
- See Also:
- Wikipedia
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTopologicalOrderAlgo.IResultA result object of aTopologicalOrderAlgoalgorithm forIntGraph.static interfaceTopologicalOrderAlgo.Result<V,E>A result object of aTopologicalOrderAlgoalgorithm.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
TopologicalOrderAlgo.Result<V,E>computeTopologicalSorting(Graph<V,E> g)Compute the topological order of a DAG vertices.static TopologicalOrderAlgonewInstance()Create a new topological order algorithm object.
-
-
-
Method Detail
-
computeTopologicalSorting
<V,E> TopologicalOrderAlgo.Result<V,E> computeTopologicalSorting(Graph<V,E> g)
Compute the topological order of a DAG vertices.If
gisIntGraph, the returned object isTopologicalOrderAlgo.IResult.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a directed acyclic graph (DAG).- Returns:
- a result object containing the computed order
- Throws:
IllegalArgumentException- if the graph is not DAG
-
newInstance
static TopologicalOrderAlgo newInstance()
Create a new topological order algorithm object.This is the recommended way to instantiate a new
TopologicalOrderAlgoobject.- Returns:
- a default implementation of
TopologicalOrderAlgo
-
-