Interface CyclesEnumerator
-
public interface CyclesEnumeratorAn algorithm that enumerate all cycles in a graph.Given a graph \(G = (V, E)\), a cycle is a path \(P = (v_1, v_2, \ldots, v_k), v_i \in V, (v_i,v_{i+1}) \in E\) such that \(v_1 = v_k\). There might be exponentially many cycles in a graph, and algorithms implementing this interface enumerate over all of them (use an
Iteratoravoiding storing all of them in memory).Use
newInstance()to get a default implementation of this interface. A builder obtained viabuilder()may support different options to obtain different implementations.- Author:
- Barak Ugav
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCyclesEnumerator.BuilderA builder forCyclesEnumeratorobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V,E>
List<Path<V,E>>allCycles(Graph<V,E> g)Find all cycles in the given graph.static CyclesEnumerator.Builderbuilder()Create a new cycles enumeration algorithm builder.<V,E>
Iterator<Path<V,E>>cyclesIter(Graph<V,E> g)Iterate over all cycles in the given graph.static CyclesEnumeratornewInstance()Create a new algorithm for cycles enumerating.
-
-
-
Method Detail
-
cyclesIter
<V,E> Iterator<Path<V,E>> cyclesIter(Graph<V,E> g)
Iterate over all cycles in the given graph.If
gisIntGraph, the returned iterator will iterate overIPathobjects.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a graph- Returns:
- an iterator that iteration over all cycles in the graph
-
allCycles
default <V,E> List<Path<V,E>> allCycles(Graph<V,E> g)
Find all cycles in the given graph.The number of cycles may be large, and its recommend to use
cyclesIter(Graph)to avoid storing all the cycles in memory at once.If
gisIntGraph, the returned list will containIPathobjects.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a graph- Returns:
- a list of all cycles in the graph
-
newInstance
static CyclesEnumerator newInstance()
Create a new algorithm for cycles enumerating.This is the recommended way to instantiate a new
CyclesEnumeratorobject. TheCyclesEnumerator.Buildermight support different options to obtain different implementations.- Returns:
- a default implementation of
CyclesEnumerator
-
builder
static CyclesEnumerator.Builder builder()
Create a new cycles enumeration algorithm builder.Use
newInstance()for a default implementation.- Returns:
- a new builder that can build
CyclesEnumeratorobjects
-
-