Class TopologicalSort

java.lang.Object
icyllis.arc3d.engine.TopologicalSort

public final class TopologicalSort extends Object
Provides a depth-first-search topological sort algorithm for simple directed acyclic graphs.
  • Constructor Details

    • TopologicalSort

      public TopologicalSort()
  • Method Details

    • topologicalSort

      public static <T> void topologicalSort(List<T> graph, TopologicalSort.Access<T> access)
      Topologically sort the nodes in 'graph'. For this sort, when node 'i' depends on node 'j' it means node 'j' must appear in the result before node 'i'.

      The graph to sort must be directed, must not allow self loops, and must not contain cycles. Otherwise, IllegalStateException will be thrown and the contents of 'graph' will be in some arbitrary state.

      Type Parameters:
      T - the node type of the graph
      Parameters:
      graph - the directed acyclic graph to sort
      access - the node access
      Throws:
      IllegalStateException - if the graph contains loops