Modifier and Type | Field and Description |
---|---|
private Graph |
mGraph
The partition that has to be sorted.
|
private int[] |
mInDegree
An array that contains the number of incoming edges to a node.
|
private Map |
mIndexMap
A Map that returns the index into mInDegree map for a particular node
in graph.
|
private int |
mOrder
The number of nodes in the graph.
|
private List<GraphNode> |
mQueue
The internal list of nodes that contains the nodes to be traversed.
|
Constructor and Description |
---|
TopologicalSortIterator(Graph graph)
The overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns whether there are more nodes to be traversed in the graph or not.
|
private int |
index(String id)
Returns the index of a particular node.
|
void |
initialize()
Initializes the inDegree for each node of the partition.
|
Object |
next()
Returns the next node to be traversed
|
void |
remove()
Removes a node from the graph.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
private Graph mGraph
private int[] mInDegree
private Map mIndexMap
mInDegree
private List<GraphNode> mQueue
private int mOrder
public TopologicalSortIterator(Graph graph)
p
- the graph that has to be sorted.public void initialize()
public boolean hasNext()
public Object next()
public void remove()
private int index(String id)
id
- the id of the node.