For using the igraph C library
igraph_error_t igraph_find_cycle(const igraph_t *graph, igraph_vector_int_t *vertices, igraph_vector_int_t *edges, igraph_neimode_t mode);
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 returns a cycle of the graph, if there is one. If the graph is acyclic, it returns empty vectors.
Arguments:

The input graph. 

Pointer to an integer vector. If a cycle is found, its vertices will be stored here. Otherwise the vector will be empty. 

Pointer to an integer vector. If a cycle is found, its edges will be stored here. Otherwise the vector will be empty. 

A constant specifying how edge directions are
considered in directed graphs. Valid modes are:

Returns:
Error code. 
Time complexity: O(V+E), where V and E are the number of vertices and edges in the original input graph.
See also:

igraph_error_t igraph_simple_cycles( const igraph_t *graph, igraph_vector_int_list_t *vertices, igraph_vector_int_list_t *edges, igraph_neimode_t mode, igraph_integer_t min_cycle_length, igraph_integer_t max_cycle_length);
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 searches for all simple cycles using Johnson's cycle detection algorithm, and stores them in the provided vector lists. A simple cycle is a cycle (i.e. closed path) without repeated vertices.
Reference:
Johnson DB: Finding all the elementary circuits of a directed graph. SIAM J. Comput. 4(1):7784. https://doi.org/10.1137/0204007
Arguments:

The graph to search for cycles in. 

The vertex IDs of each cycle will be stored here. 

The edge IDs of each cycle will be stored here. 

A constant specifying how edge directions are
considered in directed graphs. Valid modes are:


Limit the minimum length of cycles to search for. Pass a negative value to search for all cycles. 

Limit the maximum length of cycles to search for. Pass a negative value to search for all cycles. 
See also:

Returns:
Error code. 
igraph_error_t igraph_simple_cycles_callback( const igraph_t *graph, igraph_neimode_t mode, igraph_integer_t min_cycle_length, igraph_integer_t max_cycle_length, igraph_cycle_handler_t *callback, void *arg);
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 searches for all simple cycles using Johnson's cycle detection algorithm, and calls a function for each. A simple cycle is a cycle (i.e. closed path) without repeated vertices.
Reference:
Johnson DB: Finding all the elementary circuits of a directed graph.
SIAM J. Comput. 4(1):7784.
https://doi.org/10.1137/0204007
See also: igraph_simple_cycles_callback()
Arguments:

The graph to search for 

A constant specifying how edge directions are
considered in directed graphs. Valid modes are:


Limit the minimum length of cycles to search for. Pass a negative value to search for all cycles. 

Limit the maximum length of cycles to search for. Pass a negative value to search for all cycles. 

A function to call for each cycle that is found.
See also 

This parameter will be passed to 
See also:

Returns:
Error code. 
typedef igraph_error_t igraph_cycle_handler_t( const igraph_vector_int_t *vertices, const igraph_vector_int_t *edges, void *arg);
Callback type, called by igraph_simple_cycles_callback()
when
a cycle is found.
Arguments:

The vertices of the current cycle. Must not be modified. 

The edges of the current cycle. Must not be modified. 

The extra parameter passed to 
Returns:
Error code; 
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 zerolength 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. The first and
last vertex in the vector will be the same. 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 zerolength 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 breadthfirst search tree of the graph.
Edge directions are ignored. Multiedges and selfloops 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. Multiedges and selfloops are supported.
References:
Horton, J. D. (1987) A polynomialtime 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 → 