hudson.util
Class CyclicGraphDetector<N>
java.lang.Object
hudson.util.CyclicGraphDetector<N>
public abstract class CyclicGraphDetector<N>
- extends Object
Traverses a directed graph and if it contains any cycle, throw an exception.
- Author:
- Kohsuke Kawaguchi
Method Summary |
protected abstract Iterable<? extends N> |
getEdges(N n)
List up edges from the given node (by listing nodes that those edges point to.) |
List<N> |
getSorted()
Returns all the nodes in the topologically sorted order. |
protected void |
reactOnCycle(N q,
List<N> cycle)
React on detected cycles - default implementation throws an exception. |
void |
run(Iterable<? extends N> allNodes)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CyclicGraphDetector
public CyclicGraphDetector()
run
public void run(Iterable<? extends N> allNodes)
throws CyclicGraphDetector.CycleDetectedException
- Throws:
CyclicGraphDetector.CycleDetectedException
getSorted
public List<N> 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
protected abstract Iterable<? extends N> getEdges(N n)
- List up edges from the given node (by listing nodes that those edges point to.)
- Returns:
- Never null.
reactOnCycle
protected void reactOnCycle(N q,
List<N> cycle)
throws CyclicGraphDetector.CycleDetectedException
- React on detected cycles - default implementation throws an exception.
- Parameters:
q
- cycle
-
- Throws:
CyclicGraphDetector.CycleDetectedException
Copyright © 2004-2013. All Rights Reserved.