private static IEnumerable <TVertex> IsolatedVerticesIterator <TVertex, TEdge>( IBidirectionalGraph <TVertex, TEdge> visitedGraph) where TEdge : IEdge <TVertex> { foreach (var v in visitedGraph.Vertices) { if (visitedGraph.Degree(v) == 0) { yield return(v); } } }
private static void AssertDegreeSumEqualsTwiceEdgeCount <TVertex, TEdge>( [NotNull] IBidirectionalGraph <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { int totalDegree = 0; foreach (TVertex vertex in graph.Vertices) { totalDegree += graph.Degree(vertex); } Assert.AreEqual(graph.EdgeCount * 2, totalDegree); }
public void DegreeSumEqualsTwiceEdgeCount( [PexAssumeNotNull] IBidirectionalGraph <string, Edge <string> > graph) { int edgeCount = graph.EdgeCount; int degCount = 0; foreach (string v in graph.Vertices) { degCount += graph.Degree(v); } Assert.AreEqual(edgeCount * 2, degCount); }
public void DegreeSumEqualsTwiceEdgeCount <TVertex, TEdge>( [NotNull] IBidirectionalGraph <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { int edgeCount = graph.EdgeCount; int degCount = 0; foreach (TVertex vertex in graph.Vertices) { degCount += graph.Degree(vertex); } Assert.AreEqual(edgeCount * 2, degCount); }
public static IEnumerable <TVertex> IsolatedVertices <TVertex, TEdge>( IBidirectionalGraph <TVertex, TEdge> visitedGraph) where TEdge : IEdge <TVertex> { GraphContracts.AssumeNotNull(visitedGraph, "visitedGraph"); foreach (var v in visitedGraph.Vertices) { if (visitedGraph.Degree(v) == 0) { yield return(v); } } }
private void DegreeSumEqualsTwiceEdgeCount <TVertex, TEdge>( IBidirectionalGraph <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { int edgeCount = graph.EdgeCount; int degCount = 0; foreach (var v in graph.Vertices) { degCount += graph.Degree(v); } Assert.Equal(edgeCount * 2, degCount); }