Class CycleDetector
java.lang.Object
com.tngtech.archunit.library.cycle_detection.CycleDetector
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondetectCycles(Collection<NODE> nodes, Collection<EDGE> edges) Detects cycles in directed graphs consisting of nodes of typeNODEwhich are connected by directed edges of typeEDGE.
All reported cycles are "simple" cycles, i.e.
-
Method Details
-
detectCycles
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) public static <NODE,EDGE extends Edge<NODE>> Cycles<EDGE> detectCycles(Collection<NODE> nodes, Collection<EDGE> edges) Detects cycles in directed graphs consisting of nodes of typeNODEwhich are connected by directed edges of typeEDGE.
All reported cycles are "simple" cycles, i.e. they pass each node at most once. The algorithm reports all such simple cycles, even if nodes / edges are already part of another cycle. Consider the following case:
Then both cycles, red and blue, would be reported.
For performance reasons theCycleDetectorhas a maximum number of cycles to detect. Once this limit is reached the algorithm will terminate and all cycles so far will be reported. For further information please refer toCycles.maxNumberOfCyclesReached().
Note that the given edges must only reference the given nodes as theiroriginandtargetor an exception will be thrown.
Also, the passedNODEtypes must implement an appropriate and reasonably performantObject.equals(Object)andObject.hashCode().- Parameters:
nodes- The nodes of the graph to createedges- The edges connecting the nodes of the graph- Returns:
- All cycles within the graph created from the passed nodes and edges.
-