cytoscape.util
Class TopologicalSort
java.lang.Object
cytoscape.util.TopologicalSort
public class TopologicalSort
- extends Object
Implements topological sorting of nodes in a graph.
See for example http://en.wikipedia.org/wiki/Topological_sorting (the Tarjan algorithm)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TopologicalSort
public TopologicalSort()
sort
public static List<TopoGraphNode> sort(Collection<TopoGraphNode> nodes)
throws IllegalStateException
- Parameters:
nodes
- the list of all nodesedges
- the edges that connect the nodes that need to be sorted.
- Returns:
- the topological order
- Throws:
IllegalStateException
- if a cycle has been detected
N.B. it might be a good idea to make sure that whatever the concrete type of the nodes in
"nodes" are has a toString() method that returns the name of a node since this method
will be used if a cycle has been detected to report one of the nodes in the cycle.
Copyright 2010 Cytoscape Consortium. All rights reserved.