public final class TopSort extends Stack<SortedGraphNode>
Modifier and Type | Field and Description |
---|---|
private boolean |
forward
are we processing the graph in forward order?
|
private SortedGraphNode |
lastNumberedNode
the last node to get a number
|
private int |
sortMarker
the "visited" marker to use
|
private int |
sortNumber
the next "number" to give out
|
Modifier | Constructor and Description |
---|---|
private |
TopSort()
Prevent instantiation
|
Modifier and Type | Method and Description |
---|---|
static SortedGraphNode |
buildTopological(TopSortInterface graph,
boolean forward) |
private void |
DFS(SortedGraphNode node,
int numNodes)
Depth-first numbering in a non-recursive manner
|
compare, copy, empty, getTOS, isEmpty, iterator, peek, pop, push, shallowCopy, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
private int sortMarker
private int sortNumber
private SortedGraphNode lastNumberedNode
private boolean forward
private TopSort()
public static SortedGraphNode buildTopological(TopSortInterface graph, boolean forward)
graph
- the graphforward
- should we treat edges as forward?
This is the second version of the implementation
(see CVS file for older one)private void DFS(SortedGraphNode node, int numNodes)
node
- the root nodenumNodes
- the number of nodes in this graph