T
 the type of the nodespublic class Digraph<T> extends Object
A directed graph is a data structure consisting of nodes and arrows connecting those nodes which are called edges. In a directed graph edges are ordered pairs of respectively source and target nodes.
This implementation is adapted to small inmemory graphs.
Constructor and Description 

Digraph(Map<T,Collection<T>> spec)
Constructs a directed graph from a specification Map.

Modifier and Type  Method and Description 

List<T> 
sort()
Sort nodes in a topological ordering assuming that this graph is acyclic.

public Digraph(Map<T,Collection<T>> spec) throws IllegalArgumentException
spec
 the map defining a set of source nodes (keys) that are linked to a collection
of adjacent target nodes (values). Both keys and values must not be null
.IllegalArgumentException
 when a target node is not present in the sources nodes.public List<T> sort() throws IllegalStateException
A graph without cycles is often called a Directed Acyclic Graph (DAG).
IllegalStateException
 when this graph contains a cycle.