public class Topological
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int[] |
mInDegree
An array that contains the number of incoming edges to a node.
|
private java.util.Map |
mIndexMap
A Map that returns the index into mInDegree map for a particular node
in graph.
|
private Partition |
mPartition
The partition that has to be sorted.
|
Constructor and Description |
---|
Topological(Partition p)
The overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Map |
childrenRepresentation()
Returns a map that is index by GraphNode ID's and each value is the list
of ID's of children of that GraphNode.
|
private int |
index(java.lang.String id)
Returns the index of a particular node.
|
void |
initialize()
Initializes the inDegree for each node of the partition.
|
java.util.List |
sort()
Topologically sorts the partition and returns a List of
GraphNode elements. |
private Partition mPartition
private int[] mInDegree
private java.util.Map mIndexMap
mInDegree
public Topological(Partition p)
p
- the partition that has to be sorted.public void initialize()
public java.util.List sort()
GraphNode
elements. The iterator of the list, returns
the elements in the topological order.GraphNode
objectsprotected java.util.Map childrenRepresentation()
private int index(java.lang.String id)
id
- the id of the node.