Interface TopologicalSort<T>

Type Parameters:
T - graph node type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TopologicalSort<T>
Topological sorting procedure on a graph. Each procedure returns some topological sorting of a graph as a list of nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(Graph<T,?> graph)
    Returns a list of notes denoting a topological sorting of graph.
    static <T> TopologicalSort<T>
    dfs()
    Returns a topological sorting procedure which:
  • Method Details

    • dfs

      static <T> TopologicalSort<T> dfs()
      Returns a topological sorting procedure which:
      uses depth-first search to visit nodes
      throws IllegalStateException when executed on a cyclic graph
      has runtime O(V + E), space O(V) (V = number of nodes, E = number of edges)
      
    • apply

      List<T> apply(Graph<T,?> graph)
      Returns a list of notes denoting a topological sorting of graph.