Interface EulerianTourAlgo
-
public interface EulerianTourAlgo
Eulerian tour calculation algorithm.An Eulerian tour is a tour that visits every edge exactly once (allowing for revisiting vertices). For a connected undirected graph, if all vertices have an even degree, an Eulerian cycle will be found. If exactly two vertices have an odd degree, called \(s,t\), an Eulerian tour that start at \(s\) and ends at \(t\) exists. For any other vertices degrees an Eulerian tour does not exists. For a strongly connected directed graph, the in-degree and out-degree of each vertex must be equal for an Eulerian cycle to exists. If exactly one vertex \(s\) has one more out-edge than in-edges, and one vertex \(t\) has one more in-edge than out-edges, an Eulerian tour that start at \(s\) and ends at \(t\) exists.
Use
newInstance()
to get a default implementation of this interface. A builder obtained vianewBuilder()
may support different options to obtain different implementations.- Author:
- Barak Ugav
- See Also:
- Wikipedia
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
EulerianTourAlgo.Builder
A builder forEulerianTourAlgo
objects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
Path<V,E>computeEulerianTour(Graph<V,E> g)
Compute an Eulerian tour in the graph that visit all edges exactly once.static EulerianTourAlgo.Builder
newBuilder()
Create a new Eulerian tour algorithm builder.static EulerianTourAlgo
newInstance()
Create a new Eulerian tour computation algorithm.
-
-
-
Method Detail
-
computeEulerianTour
<V,E> Path<V,E> computeEulerianTour(Graph<V,E> g)
Compute an Eulerian tour in the graph that visit all edges exactly once.The graph is assumed to be (strongly) connected. Either a cycle or tour will be found, depending on the vertices degrees.
- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graph- Returns:
- an Eulerian tour that visit all edges of the graph exactly once
- Throws:
IllegalArgumentException
- if there is no Eulerian tour in the graph
-
newInstance
static EulerianTourAlgo newInstance()
Create a new Eulerian tour computation algorithm.This is the recommended way to instantiate a new
EulerianTourAlgo
object. TheEulerianTourAlgo.Builder
might support different options to obtain different implementations.- Returns:
- a default implementation of
EulerianTourAlgo
-
newBuilder
static EulerianTourAlgo.Builder newBuilder()
Create a new Eulerian tour algorithm builder.Use
newInstance()
for a default implementation.- Returns:
- a new builder that can build
EulerianTourAlgo
objects
-
-