public IEnumerable <IEnumerable <TEdge> > HoffmanPavleyRankedShortestPath <TVertex, TEdge>( [PexAssumeNotNull] IBidirectionalGraph <TVertex, TEdge> g, [PexAssumeNotNull] Dictionary <TEdge, double> edgeWeights, TVertex rootVertex, TVertex goalVertex, int pathCount ) where TEdge : IEdge <TVertex> { //GraphConsoleSerializer.DisplayGraph((IEdgeListGraph<TVertex, TEdge>)g); PexAssert.TrueForAll(g.Edges, edgeWeights.ContainsKey); var target = new HoffmanPavleyRankedShortestPathAlgorithm <TVertex, TEdge>(g, e => edgeWeights[e]); target.ShortestPathCount = pathCount; target.Compute(rootVertex, goalVertex); double lastWeight = double.MinValue; foreach (var path in target.ComputedShortestPaths) { TestConsole.WriteLine("path: {0}", Enumerable.Sum(path, e => edgeWeights[e])); double weight = Enumerable.Sum(path, e => edgeWeights[e]); Assert.IsTrue(lastWeight <= weight, "{0} <= {1}", lastWeight, weight); Assert.AreEqual(rootVertex, Enumerable.First(path).Source); Assert.AreEqual(goalVertex, Enumerable.Last(path).Target); Assert.IsTrue(EdgeExtensions.IsPathWithoutCycles <TVertex, TEdge>(path)); lastWeight = weight; } return(target.ComputedShortestPaths); }