For using the igraph C library
These functions calculate whether an Eulerian path or cycle exists and if so, can find them.
int igraph_is_eulerian(const igraph_t *graph, igraph_bool_t *has_path, igraph_bool_t *has_cycle);
An Eulerian path traverses each edge of the graph precisely once. A closed Eulerian path is referred to as an Eulerian cycle.
Arguments:
|
The graph object. |
|
Pointer to a Boolean, will be set to true if an Eulerian path exists. |
|
Pointer to a Boolean, will be set to true if an Eulerian cycle exists. |
Returns:
Error code:
|
Time complexity: O(|V|+|E|), the number of vertices plus the number of edges.
int igraph_eulerian_cycle(const igraph_t *graph, igraph_vector_t *edge_res, igraph_vector_t *vertex_res);
Finds an Eulerian cycle, if it exists. An Eulerian cycle is a closed path that traverses each edge precisely once.
This function uses Hierholzer's algorithm.
Arguments:
|
The graph object. |
|
Pointer to an initialised vector. The indices of edges
belonging to the cycle will be stored here. May be |
|
Pointer to an initialised vector. The indices of vertices
belonging to the cycle will be stored here. May be |
Returns:
Error code:
|
Time complexity: O(|V|+|E|), the number of vertices plus the number of edges.
int igraph_eulerian_path(const igraph_t *graph, igraph_vector_t *edge_res, igraph_vector_t *vertex_res);
Finds an Eulerian path, if it exists. An Eulerian path traverses each edge precisely once.
This function uses Hierholzer's algorithm.
Arguments:
|
The graph object. |
|
Pointer to an initialised vector. The indices of edges
belonging to the path will be stored here. May be |
|
Pointer to an initialised vector. The indices of vertices
belonging to the path will be stored here. May be |
Returns:
Error code:
|
Time complexity: O(|V|+|E|), the number of vertices plus the number of edges.
← Chapter 13. Structural properties of graphs | Chapter 15. Graph visitors → |