Class DirectedGraph<T>

  • Type Parameters:
    T - type of elements which act as nodes in the graph

    public class DirectedGraph<T>
    extends java.lang.Object
    Representation of a directed graph which can be sorted by calling sort().
    Since:
    2.0.0
    Author:
    Oliver Libutzki
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectedGraph()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEdge​(T source, T target)
      Calls addNode(Object) for source and target and adds the edge to the graph.
      void addNode​(T node)
      Adds the given node to the graph
      java.util.Collection<T> getEdgeTargetsFrom​(T source)
      Returns all the targets of the edges starting at the given source.
      java.util.List<T> sort()
      Execute topological sort by using sortInternal(Object, Set, Stack) recursively.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DirectedGraph

        public DirectedGraph()
    • Method Detail

      • addNode

        public void addNode​(T node)
        Adds the given node to the graph
        Parameters:
        node - the node to be added
        Since:
        2.0.0
      • addEdge

        public void addEdge​(T source,
                            T target)
        Calls addNode(Object) for source and target and adds the edge to the graph.
        Parameters:
        source - the source node
        target - the target node
        Since:
        2.0.0
      • getEdgeTargetsFrom

        public java.util.Collection<T> getEdgeTargetsFrom​(T source)
        Returns all the targets of the edges starting at the given source.
        Parameters:
        source - the source node
        Returns:
        the target nodes
        Since:
        2.0.0