|
ADS
Algorithms and Data Structures
|
The Eulerian cycles and trails of a graph, oriented or not: a trail is a path that uses each edge exactly once, a cycle a closed trail. More...
#include "ADS/Contract.h"#include "ADS/graph/Graph.h"#include <algorithm>#include <cstddef>#include <optional>#include <utility>#include <vector>#include "ADS/graph/impl/EulerianCycle.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<Graph G> | |
| std::optional< std::vector< int > > | ADS::eulerianCycle (const G &g) |
| the nodes of an Eulerian cycle of the graph, the first node repeated at the end, or nothing if there is none; empty with no edge | |
| template<Graph G> | |
| std::optional< std::vector< int > > | ADS::eulerianTrail (const G &g) |
| the nodes of an Eulerian trail of the graph, closed (the first node repeated at the end) if there is an Eulerian cycle and open otherwise, or nothing if there is none; empty with no edge | |
| template<Graph G> | |
| std::optional< std::vector< int > > | ADS::eulerianTrail (const G &g, int s) |
| the Eulerian trail of eulerianTrail() above from the node \( s \), or nothing if no Eulerian trail starts from it; empty with no edge | |
| template<Graph G> | |
| bool | ADS::isEulerianCycle (const G &g, const std::vector< int > &c) |
| whether the nodes \( c \), the first repeated at the end, are a closed path that uses each edge of \( g \) exactly once; empty if g has no edge | |
| template<Graph G> | |
| bool | ADS::isEulerianTrail (const G &g, const std::vector< int > &c) |
| whether the nodes \( c \) are a path, open or closed, that uses each edge of \( g \) exactly once, an unoriented edge in either direction; empty if g has no edge | |
The Eulerian cycles and trails of a graph, oriented or not: a trail is a path that uses each edge exactly once, a cycle a closed trail.
The connection of the edges is not tested apart: under the conditions on the degrees the walk of Hierholzer uses every edge reachable from its start, which is every edge if and only if they are in one component, so that a walk shorter than m edges tells that there is no trail. An unoriented edge is used in one direction, the two arcs of the adjacency paired in their order, so that parallel edges are distinct edges. The theory is in Eulerian trails and other properties.
The contracts [see Contract.h]: a start given is a node; an unoriented graph has no loop; at the level of the audits, the trail found uses each edge exactly once, which isEulerianTrail() checks. The functions are defined in EulerianCycle.tpp.