Interface SimplePathsEnumerator
- All Known Implementing Classes:
SimplePathsEnumeratorAbstract
,SimplePathsEnumeratorSedgewick
Given a graph \(G=(V,E)\), a path is a sequence of edges \(e_1,e_2,\ldots,e_k\) such that \(e_i=(v_{i-1},v_i)\) and \(v_i\neq v_j\) for \(i\neq j\). A simple path is a path that does not contain a cycle, namely the vertices visited by the path are distinct. Algorithms implementing this interface find all simple paths between a source and a target vertices in a given graph. Note that there may be exponentially many simple paths between two vertices in a graph.
Use newInstance()
to get a default implementation of this interface.
- Author:
- Barak Ugav
-
Method Summary
Modifier and TypeMethodDescriptionallSimplePaths
(Graph<V, E> g, V source, V target) Find all the simple paths between a source and a target vertices in the given graph.static SimplePathsEnumerator
Create a new algorithm for simple paths enumeration.simplePathsIter
(Graph<V, E> g, V source, V target) Iterate over all the simple paths between a source and a target vertices in the given graph.
-
Method Details
-
simplePathsIter
Iterate over all the simple paths between a source and a target vertices in the given graph.If
g
is anIntGraph
, an iterator ofIPath
objects will be returned.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graphsource
- the source vertextarget
- the target vertex- Returns:
- an iterator that iteration over all simple paths between the two vertices in the graph
-
allSimplePaths
Find all the simple paths between a source and a target vertices in the given graph.If
g
is anIntGraph
, a list ofIPath
objects will be returned.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graphsource
- the source vertextarget
- the target vertex- Returns:
- a list of all simple paths between the two vertices in the graph
-
newInstance
Create a new algorithm for simple paths enumeration.This is the recommended way to instantiate a new
SimplePathsEnumerator
object.- Returns:
- a default implementation of
SimplePathsEnumerator
-