Class AllWalksSpliterator<V,A,C extends Number & Comparable<C>,E>

Type Parameters:
V - the vertex data type
A - the arrow data type
C - the cost number type
E - the element type of the path
All Implemented Interfaces:
Spliterator<OrderedPair<ImmutableList<E>,C>>, BareEnumerator<OrderedPair<ImmutableList<E>,C>>, Enumerator<OrderedPair<ImmutableList<E>,C>>

public class AllWalksSpliterator<V,A,C extends Number & Comparable<C>,E> extends AbstractEnumerator<OrderedPair<ImmutableList<E>,C>>
Iterates over all walks from a set of start vertices to a set of goal vertices using a breadth-first search.

Only enumerates walks that contain a goal once.

Expected run time: The enumeration of all walks in a graph is NP-complete. (Because counting paths is #P-complete).

Only run this algorithm on acyclic graphs. In graphs with cycles the algorithm may run out of space, and will then throw a IllegalStateException. In an acyclic graph, the algorithm will return paths (a path is a walk that only contains each vertex once).

References:

Leslie G. Valiant. (1979)
The Complexity of Enumeration and Reliability Problems. Chapter 4. Some #P-complete problems. Item 11. S-T CONNECTEDNESS math.cmu.edu
  • Constructor Details

  • Method Details

    • moveNext

      public boolean moveNext()
      Returns:
      true on success
      Throws:
      IllegalStateException - if the underlying queue runs out of space