org.jgrapht.alg.cycle
Class HierholzerEulerianCycle<V,E>
- java.lang.Object
-
- org.jgrapht.alg.cycle.HierholzerEulerianCycle<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
- EulerianCycleAlgorithm<V,E>
public class HierholzerEulerianCycle<V,E> extends java.lang.Object implements EulerianCycleAlgorithm<V,E>
An implementation of Hierholzer's algorithm for finding an Eulerian cycle in Eulerian graphs. The algorithm works with directed and undirected graphs which may contain loops and/or multiple edges. The running time is linear, i.e. O(|E|) where |E| is the cardinality of the edge set of the graph.See the Wikipedia article for details and references about Eulerian cycles and a short description of Hierholzer's algorithm for the construction of an Eulerian cycle. The original presentation of the algorithm dates back to 1873 and the following paper: Carl Hierholzer: Über die Möglichkeit, einen Linienzug ohne Wiederholung und ohne Unterbrechung zu umfahren. Mathematische Annalen 6(1), 30–32, 1873.
- Since:
- October 2016
-
-
Constructor Summary
Constructors Constructor and Description HierholzerEulerianCycle()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description GraphPath<V,E>getEulerianCycle(Graph<V,E> g)Compute an Eulerian cycle of a graph.booleanisEulerian(Graph<V,E> graph)Test whether a graph is Eulerian.
-
-
-
Method Detail
-
isEulerian
public boolean isEulerian(Graph<V,E> graph)
Test whether a graph is Eulerian. An Eulerian graph is a graph containing an Eulerian cycle.- Parameters:
graph- the input graph- Returns:
- true if the graph is Eulerian, false otherwise
-
getEulerianCycle
public GraphPath<V,E> getEulerianCycle(Graph<V,E> g)
Compute an Eulerian cycle of a graph.- Specified by:
getEulerianCyclein interfaceEulerianCycleAlgorithm<V,E>- Parameters:
g- the input graph- Returns:
- an Eulerian cycle
- Throws:
java.lang.IllegalArgumentException- in case the graph is not Eulerian
-
-
DataMelt 3.0 © DataMelt by jWork.ORG