gmm
Class DirectedGraph

java.lang.Object
  extended by gmm.DirectedGraph

public class DirectedGraph
extends java.lang.Object


Constructor Summary
DirectedGraph(int numberOfNodes)
          Creates an empty graph with the specified number of nodes.
 
Method Summary
 void add(int from, int to)
          Adds the specified edge to the graph, and others that might be needed to maintain transitive closure.
 int[] getTopologicalSort()
          Assumes that an edge exists between any pair of nodes i and j.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectedGraph

public DirectedGraph(int numberOfNodes)
Creates an empty graph with the specified number of nodes.

Method Detail

add

public void add(int from,
                int to)
Adds the specified edge to the graph, and others that might be needed to maintain transitive closure. If the graph already contains this edge or its reverse, nothing is done.

Parameters:
from -
to -

getTopologicalSort

public int[] getTopologicalSort()
Assumes that an edge exists between any pair of nodes i and j. Won't return the correct answer otherwise.

Returns:
an int array containing the nodes in topologically sorted order.