Interface CyclesEnumerator

All Known Implementing Classes:
CyclesEnumeratorAbstract, CyclesEnumeratorJohnson, CyclesEnumeratorTarjan

public interface CyclesEnumerator
An 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 Iterator avoiding storing all of them in memory).

Use newInstance() to get a default implementation of this interface.

Author:
Barak Ugav
  • Method Summary

    Modifier and Type
    Method
    Description
    <V, E> Iterator<Path<V,E>>
    cyclesIter(Graph<V,E> g)
    Iterate over all cycles in the given graph.
    Create a new algorithm for cycles enumerating.
  • Method Details

    • cyclesIter

      <V, E> Iterator<Path<V,E>> cyclesIter(Graph<V,E> g)
      Iterate over all cycles in the given graph.

      If g is IntGraph, the returned iterator will iterate over IPath objects.

      Type Parameters:
      V - the vertices type
      E - the edges type
      Parameters:
      g - a graph
      Returns:
      an iterator that iteration over 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 CyclesEnumerator object.

      Returns:
      a default implementation of CyclesEnumerator