Package org.jgrapht.alg.cycle
Class CycleDetector<V,E>
- java.lang.Object
- 
- org.jgrapht.alg.cycle.CycleDetector<V,E>
 
- 
- Type Parameters:
- V- the graph vertex type
- E- the graph edge type
 
 public class CycleDetector<V,E> extends Object Performs cycle detection on a graph. The inspected graph is specified at construction time and cannot be modified. Currently, the detector supports only directed graphs.- Author:
- John V. Sichi
 
- 
- 
Constructor SummaryConstructors Constructor Description CycleDetector(Graph<V,E> graph)Creates a cycle detector for the specified graph.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandetectCycles()Performs yes/no cycle detection on the entire graph.booleandetectCyclesContainingVertex(V v)Performs yes/no cycle detection on an individual vertex.Set<V>findCycles()Finds the vertex set for the subgraph of all cycles.Set<V>findCyclesContainingVertex(V v)Finds the vertex set for the subgraph of all cycles which contain a particular vertex.
 
- 
- 
- 
Method Detail- 
detectCyclespublic boolean detectCycles() Performs yes/no cycle detection on the entire graph.- Returns:
- true iff the graph contains at least one cycle
 
 - 
detectCyclesContainingVertexpublic boolean detectCyclesContainingVertex(V v) Performs yes/no cycle detection on an individual vertex.- Parameters:
- v- the vertex to test
- Returns:
- true if v is on at least one cycle
 
 - 
findCyclespublic Set<V> findCycles() Finds the vertex set for the subgraph of all cycles.- Returns:
- set of all vertices which participate in at least one cycle in this graph
 
 - 
findCyclesContainingVertexpublic Set<V> findCyclesContainingVertex(V v) Finds the vertex set for the subgraph of all cycles which contain a particular vertex.REVIEW jvs 25-Aug-2006: This implementation is not guaranteed to cover all cases. If you want to be absolutely certain that you report vertices from all cycles containing v, it's safer (but less efficient) to use StrongConnectivityAlgorithm instead and return the strongly connected component containing v. - Parameters:
- v- the vertex to test
- Returns:
- set of all vertices reachable from v via at least one cycle
 
 
- 
 
-