private static void RunDagShortestPathAndCheck <TVertex, TEdge>( [NotNull] IVertexListGraph <TVertex, TEdge> graph, [NotNull] TVertex root, [NotNull] IDistanceRelaxer relaxer) where TEdge : IEdge <TVertex> { var algorithm = new DagShortestPathAlgorithm <TVertex, TEdge>( graph, _ => 1.0, relaxer); algorithm.InitializeVertex += vertex => { Assert.AreEqual(GraphColor.White, algorithm.VerticesColors[vertex]); }; algorithm.DiscoverVertex += vertex => { Assert.AreEqual(GraphColor.Gray, algorithm.VerticesColors[vertex]); }; algorithm.StartVertex += vertex => { Assert.AreNotEqual(GraphColor.Black, algorithm.VerticesColors[vertex]); }; algorithm.ExamineVertex += vertex => { Assert.AreEqual(GraphColor.Gray, algorithm.VerticesColors[vertex]); }; algorithm.FinishVertex += vertex => { Assert.AreEqual(GraphColor.Black, algorithm.VerticesColors[vertex]); }; var predecessors = new VertexPredecessorRecorderObserver <TVertex, TEdge>(); using (predecessors.Attach(algorithm)) algorithm.Compute(root); Assert.AreEqual(graph.VertexCount, algorithm.VerticesColors.Count); foreach (TVertex vertex in graph.Vertices) { Assert.AreEqual(GraphColor.Black, algorithm.VerticesColors[vertex]); } CollectionAssert.IsNotEmpty(algorithm.GetDistances()); Assert.AreEqual(graph.VertexCount, algorithm.GetDistances().Count()); Verify(algorithm, predecessors); }