For using the igraph C library
These functions calculate whether an Eulerian path or cycle exists and if so, can find them.
igraph_error_t 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.
Must not be |
|
Pointer to a Boolean, will be set to true if an Eulerian cycle exists.
Must not be |
Returns:
Error code:
|
Time complexity: O(|V|+|E|), the number of vertices plus the number of edges.
igraph_error_t igraph_eulerian_cycle( const igraph_t *graph, igraph_vector_int_t *edge_res, igraph_vector_int_t *vertex_res);
Finds an Eulerian cycle, if it exists. An Eulerian cycle is a closed path that traverses each edge precisely once.
If the graph has no edges, a zero-length cycle is returned.
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.
igraph_error_t igraph_eulerian_path( const igraph_t *graph, igraph_vector_int_t *edge_res, igraph_vector_int_t *vertex_res);
Finds an Eulerian path, if it exists. An Eulerian path traverses each edge precisely once.
If the graph has no edges, a zero-length path is returned.
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.
igraph_error_t igraph_fundamental_cycles(const igraph_t *graph, igraph_vector_int_list_t *result, igraph_integer_t start_vid, igraph_integer_t bfs_cutoff, const igraph_vector_t *weights);
This function is experimental and its signature is not considered final yet. We reserve the right to change the function signature without changing the major version of igraph. Use it at your own risk.
This function computes a fundamental cycle basis associated with a breadth-first search tree of the graph.
Edge directions are ignored. Multi-edges and self-loops are supported.
Arguments:
|
The graph object. |
|
An initialized integer vector list. The result will be stored here, each vector containing the edge IDs of a basis element. |
|
If negative, a complete fundamental cycle basis is returned. If a vertex ID, the fundamental cycles associated with the BFS tree rooted in that vertex will be returned, only for the weakly connected component containing that vertex. |
|
If negative, a complete cycle basis is returned. Otherwise, only
cycles of length |
|
Currently unused. |
Returns:
Error code. |
Time complexity: O(|V| + |E|).
igraph_error_t igraph_minimum_cycle_basis(const igraph_t *graph, igraph_vector_int_list_t *result, igraph_integer_t bfs_cutoff, igraph_bool_t complete, igraph_bool_t use_cycle_order, const igraph_vector_t *weights);
This function is experimental and its signature is not considered final yet. We reserve the right to change the function signature without changing the major version of igraph. Use it at your own risk.
This function computes a minimum weight cycle basis of a graph. Currently, a modified version of Horton's algorithm is used that allows for cutoffs.
Edge directions are ignored. Multi-edges and self-loops are supported.
References:
Horton, J. D. (1987) A polynomial-time algorithm to find the shortest cycle basis of a graph, SIAM Journal on Computing, 16 (2): 358–366. https://doi.org/10.1137%2F0216026
Arguments:
|
The graph object. |
|
An initialized integer vector list, the elements of the cycle basis will be stored here as vectors of edge IDs. |
|
If negative, an exact minimum cycle basis is returned. Otherwise
only those cycles in the result will be part of some minimum cycle basis which
are of size |
|
Boolean value. Used only when |
|
If true, each cycle is returned in natural order: the edge IDs will appear ordered along the cycle. This comes at a small performance cost. If false, no guarantees are given about the ordering of edge IDs within cycles. This parameter exists solely to control performance tradeoffs. |
|
Currently unused. |
Returns:
Error code. |
Time complexity: TODO.
← Chapter 13. Structural properties of graphs | Chapter 15. Graph visitors → |