Package org.graphstream.algorithm
Class TopologicalSortDFS
java.lang.Object
org.graphstream.algorithm.TopologicalSortDFS
- All Implemented Interfaces:
Algorithm
public class TopologicalSortDFS extends Object implements Algorithm
Implementation of depth first search algorithm for a topological sorting of a directed acyclic graph (DAG).
Every DAG has at least one topological ordering and this is a algorithm known for constructing a
topological ordering in linear time.
- Computational Complexity :
- O(VxE) time, where V and E are the number of vertices and edges respectively.
- Scientific Reference :
- Tarjan, Robert E. (1976), "Edge-disjoint spanning trees and depth-first search", Acta Informatica, 6 (2): 171–185
-
Constructor Summary
Constructors Constructor Description TopologicalSortDFS()
-
Method Summary
Modifier and Type Method Description void
compute()
Run the algorithm.String
defaultResult()
List<org.graphstream.graph.Node>
getSortedNodes()
gets sorted list of the given graphvoid
init(org.graphstream.graph.Graph theGraph)
Initialization of the algorithm.
-
Constructor Details
-
TopologicalSortDFS
public TopologicalSortDFS()
-
-
Method Details
-
init
public void init(org.graphstream.graph.Graph theGraph)Description copied from interface:Algorithm
Initialization of the algorithm. This method has to be called before theAlgorithm.compute()
method to initialize or reset the algorithm according to the new given graph. -
compute
public void compute()Description copied from interface:Algorithm
Run the algorithm. TheAlgorithm.init(Graph)
method has to be called before computing.- Specified by:
compute
in interfaceAlgorithm
- See Also:
Algorithm.init(Graph)
-
getSortedNodes
gets sorted list of the given graph- Returns:
- topological sorted list of nodes
-
defaultResult
-