Class TopoSort<T>
- java.lang.Object
-
- net.stoerr.ai.aigenpipeline.commandline.TopoSort<T>
-
public class TopoSort<T> extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
TopoSort.Edge<T>
static class
TopoSort.TopoSortCycleException
Is thrown to notify that there is a cycle regarding the given node.
-
Constructor Summary
Constructors Constructor Description TopoSort()
-
-
-
Method Detail
-
sort
public List<T> sort() throws TopoSort.TopoSortCycleException
Calculates topologically sorted list of nodes. If a cycle is detected, an IllegalArgumentException is thrown.- Returns:
- sorted list of nodes - if there is an edge from node A to node B, then A will appear before B in the list
- Throws:
TopoSort.TopoSortCycleException
- if a cycle is detected
-
visit
protected void visit(T node, Set<T> visited, Set<T> visiting, List<T> result) throws TopoSort.TopoSortCycleException
- Throws:
TopoSort.TopoSortCycleException
-
-