- java.lang.Object
-
- org.jgrapht.alg.cycle.JohnsonSimpleCycles<V,E>
-
- Type Parameters:
V- the vertex type.E- the edge type.
- All Implemented Interfaces:
DirectedSimpleCycles<V,E>
public class JohnsonSimpleCycles<V,E> extends java.lang.Object implements DirectedSimpleCycles<V,E>
Find all simple cycles of a directed graph using the Johnson's algorithm.See:
D.B.Johnson, Finding all the elementary circuits of a directed graph, SIAM J. Comput., 4 (1975), pp. 77-84.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<V>blockedprivate java.util.Map<V,java.util.Set<V>>bSetsprivate java.util.function.Consumer<java.util.List<V>>cycleConsumerprivate java.util.List<java.util.Set<V>>foundSCCsprivate Graph<V,E>graphprivate intindexprivate V[]iToVprivate java.util.ArrayDeque<V>pathprivate java.util.Set<V>pathSetprivate java.util.ArrayDeque<V>stackprivate java.util.Map<V,java.lang.Integer>vIndexprivate java.util.Map<V,java.lang.Integer>vLowlinkprivate java.util.Map<V,java.lang.Integer>vToI
-
Constructor Summary
Constructors Constructor Description JohnsonSimpleCycles(Graph<V,E> graph)Create a simple cycle finder for the specified graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearMinSCCState()private voidclearState()private booleanfindCyclesInSCG(int startIndex, int vertexIndex, Graph<V,E> scg)private Pair<Graph<V,E>,java.lang.Integer>findMinSCSG(int startIndex)private java.util.List<java.util.Set<V>>findSCCS(int startIndex)voidfindSimpleCycles(java.util.function.Consumer<java.util.List<V>> consumer)Find the simple cycles of the graph.private java.util.Set<V>getBSet(V v)private voidgetSCCs(int startIndex, int vertexIndex)private voidinitMinSCGState()private voidinitState(java.util.function.Consumer<java.util.List<V>> consumer)private java.lang.IntegertoI(V vertex)private VtoV(java.lang.Integer i)private voidunblock(V vertex)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.alg.cycle.DirectedSimpleCycles
findSimpleCycles
-
-
-
-
Field Detail
-
cycleConsumer
private java.util.function.Consumer<java.util.List<V>> cycleConsumer
-
iToV
private V[] iToV
-
vToI
private java.util.Map<V,java.lang.Integer> vToI
-
blocked
private java.util.Set<V> blocked
-
stack
private java.util.ArrayDeque<V> stack
-
foundSCCs
private java.util.List<java.util.Set<V>> foundSCCs
-
index
private int index
-
vIndex
private java.util.Map<V,java.lang.Integer> vIndex
-
vLowlink
private java.util.Map<V,java.lang.Integer> vLowlink
-
path
private java.util.ArrayDeque<V> path
-
pathSet
private java.util.Set<V> pathSet
-
-
Method Detail
-
findSimpleCycles
public void findSimpleCycles(java.util.function.Consumer<java.util.List<V>> consumer)
Find the simple cycles of the graph.- Specified by:
findSimpleCyclesin interfaceDirectedSimpleCycles<V,E>- Parameters:
consumer- Consumer that will be called with each cycle found.
-
findSCCS
private java.util.List<java.util.Set<V>> findSCCS(int startIndex)
-
getSCCs
private void getSCCs(int startIndex, int vertexIndex)
-
unblock
private void unblock(V vertex)
-
initState
private void initState(java.util.function.Consumer<java.util.List<V>> consumer)
-
clearState
private void clearState()
-
initMinSCGState
private void initMinSCGState()
-
clearMinSCCState
private void clearMinSCCState()
-
toI
private java.lang.Integer toI(V vertex)
-
toV
private V toV(java.lang.Integer i)
-
-