/// <summary> /// Computes the number of Eulerian trails in the graph. /// </summary> /// <param name="graph">Graph to visit.</param> /// <returns>Number of Eulerian trails.</returns> public static int ComputeEulerianPathCount( IVertexAndEdgeListGraph <TVertex, TEdge> graph) { if (graph is null) { throw new ArgumentNullException(nameof(graph)); } if (graph.EdgeCount < graph.VertexCount) { return(0); } int odd = graph.OddVertices().Count(); if (odd == 0) { return(1); } if (odd % 2 != 0) { return(0); } return(odd / 2); }