Class TopologicalSorter<N>

java.lang.Object
pascal.taie.util.graph.TopologicalSorter<N>
Type Parameters:
N - type of nodes

public class TopologicalSorter<N> extends Object
Topologically sorts a directed graph using DFS. It is assumed that the given graph is a direct acyclic graph (DAG).
  • Constructor Details

    • TopologicalSorter

      public TopologicalSorter(Graph<N> graph)
    • TopologicalSorter

      public TopologicalSorter(Graph<N> graph, boolean reverse)
    • TopologicalSorter

      public TopologicalSorter(Graph<N> graph, List<N> preservedOrder)
      Computes a topological soring of a graph, while the client code wishes to preserve some ordering in the sorting result. If preserved order conflicts the topological order, the latter is respected.
      Parameters:
      graph - the graph
      preservedOrder - the order of the nodes that the client code wishes to preserve
  • Method Details

    • get

      public List<N> get()
      Returns:
      the topologically sorted list.