Package org.mpi_sws.jmc.strategies.trust
Class ExecutionGraph.TopologicalSorter
java.lang.Object
org.mpi_sws.jmc.strategies.trust.ExecutionGraph.TopologicalSorter
- Enclosing class:
ExecutionGraph
Topological sorter for the execution graph.
Sorts the nodes in topological order and throws an exception if the graph has cycles.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when the graph has cycles. -
Constructor Summary
ConstructorsConstructorDescriptionTopologicalSorter(ExecutionGraph graph) Initializes a new topological sorter for the given graph. -
Method Summary
Modifier and TypeMethodDescriptionsort()Sorts the graph in topological order.voidSorts the graph in topological order and visits each node using the given visitor.
-
Constructor Details
-
TopologicalSorter
Initializes a new topological sorter for the given graph.- Parameters:
graph- The graph to sort.
-
-
Method Details
-
sort
Sorts the graph in topological order.- Returns:
- The sorted list of nodes.
- Throws:
ExecutionGraph.TopologicalSorter.GraphCycleException- If the graph has cycles.
-
sortWithVisitor
public void sortWithVisitor(ExecutionGraph.ExecutionGraphNodeVisitor visitor) throws ExecutionGraph.TopologicalSorter.GraphCycleException Sorts the graph in topological order and visits each node using the given visitor.- Parameters:
visitor- The visitor to use for each node.- Throws:
ExecutionGraph.TopologicalSorter.GraphCycleException- If the graph has cycles.
-