Class CyclicGraphDetector<N>
java.lang.Object
org.ow2.proactive.process_tree_killer.CyclicGraphDetector<N>
public abstract class CyclicGraphDetector<N>
extends java.lang.Object
Traverses a directed graph and if it contains any cycle, throw an exception.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCyclicGraphDetector.CycleDetectedException -
Constructor Summary
Constructors Constructor Description CyclicGraphDetector() -
Method Summary
Modifier and Type Method Description protected abstract java.lang.Iterable<? extends N>getEdges(N n)List up edges from the given node (by listing nodes that those edges point to.)java.util.List<N>getSorted()Returns all the nodes in the topologically sorted order.protected voidreactOnCycle(N q, java.util.List<N> cycle)React on detected cycles - default implementation throws an exception.voidrun(java.lang.Iterable<? extends N> allNodes)
-
Constructor Details
-
CyclicGraphDetector
public CyclicGraphDetector()
-
-
Method Details
-
run
public void run(java.lang.Iterable<? extends N> allNodes) throws CyclicGraphDetector.CycleDetectedException -
getSorted
Returns all the nodes in the topologically sorted order. That is, if there's an edge a->b, b always come earlier than a. -
getEdges
List up edges from the given node (by listing nodes that those edges point to.)- Returns:
- Never null.
-
reactOnCycle
protected void reactOnCycle(N q, java.util.List<N> cycle) throws CyclicGraphDetector.CycleDetectedExceptionReact on detected cycles - default implementation throws an exception.- Parameters:
q-cycle-- Throws:
CyclicGraphDetector.CycleDetectedException
-