Class GraphEulerianExtensions
- Namespace
- Graph1x.Algorithms
- Assembly
- Graph1x.dll
Eulerian trails: paths and circuits that use every edge exactly once. Existence follows the classic degree conditions (balanced in/out degrees for directed graphs; zero or two odd-degree vertices for undirected ones) plus a single edge-bearing component; construction is an iterative Hierholzer walk. Multigraphs are fully supported — parallel edges are tracked by instance, which is exactly the Königsberg setting.
public static class GraphEulerianExtensions
- Inheritance
-
GraphEulerianExtensions
- Inherited Members
Methods
FindEulerianCircuit<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Finds an Eulerian circuit, or null when none exists.
public static IReadOnlyList<TEdge>? FindEulerianCircuit<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to traverse.
Returns
- IReadOnlyList<TEdge>
The circuit's edge sequence (empty for edgeless graphs), or null.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
FindEulerianPath<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Finds an Eulerian path, or null when none exists.
public static IReadOnlyList<TEdge>? FindEulerianPath<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to traverse.
Returns
- IReadOnlyList<TEdge>
The trail's edge sequence (empty for edgeless graphs), or null.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
HasEulerianCircuit<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Determines whether the graph has an Eulerian circuit (a closed trail using every edge once). Edgeless graphs trivially do.
public static bool HasEulerianCircuit<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to inspect.
Returns
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
HasEulerianPath<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Determines whether the graph has an Eulerian path (a trail using every edge once; circuits count). Edgeless graphs trivially do.
public static bool HasEulerianPath<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to inspect.
Returns
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.