Package org.graphstream.algorithm
Class TopologicalSortKahn
java.lang.Object
org.graphstream.algorithm.TopologicalSortKahn
- All Implemented Interfaces:
Algorithm
public class TopologicalSortKahn extends Object implements Algorithm
Implementation of Kahn's 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 without considering initial copying the graph and searching for source nodes.
- Computational Complexity :
- O(VxE) time, where V and E are the number of vertices and edges respectively.
- Scientific Reference :
- Kahn, Arthur B. (1962), "Topological sorting of large networks", Communications of the ACM, 5 (11): 558–562
-
Constructor Summary
Constructors Constructor Description TopologicalSortKahn()
-
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
-
TopologicalSortKahn
public TopologicalSortKahn()
-
-
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
-