public void ComputeCriticalPath <TVertex, TEdge>( IVertexListGraph <TVertex, TEdge> g) where TEdge : IEdge <TVertex> { // is this a dag ? bool isDag = g.IsDirectedAcyclicGraph(); var relaxer = DistanceRelaxers.CriticalDistance; var vertices = new List <TVertex>(g.Vertices); foreach (var root in vertices) { if (isDag) { Search(g, root, relaxer); } else { try { Search(g, root, relaxer); Assert.Fail("should have found the acyclic graph"); } catch (NonAcyclicGraphException) { Console.WriteLine("NonAcyclicGraphException caught (as expected)"); } } } }
private static void Compute <TVertex, TEdge>([NotNull] IVertexListGraph <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { // Is this a dag? bool isDag = graph.IsDirectedAcyclicGraph(); IDistanceRelaxer relaxer = DistanceRelaxers.ShortestDistance; var vertices = new List <TVertex>(graph.Vertices); foreach (TVertex root in vertices) { if (isDag) { Search(graph, root, relaxer); } else { Assert.Throws <NonAcyclicGraphException>(() => Search(graph, root, relaxer)); } } }
private static void DagAlgorithm_Test <TVertex, TEdge>( [NotNull] IVertexListGraph <TVertex, TEdge> graph, [NotNull] IDistanceRelaxer relaxer) where TEdge : IEdge <TVertex> { // Is this a dag? bool isDag = graph.IsDirectedAcyclicGraph(); TVertex[] vertices = graph.Vertices.ToArray(); foreach (TVertex root in vertices) { if (isDag) { RunDagShortestPathAndCheck(graph, root, relaxer); } else { Assert.Throws <NonAcyclicGraphException>(() => RunDagShortestPathAndCheck(graph, root, relaxer)); } } }
private bool HasCycles(IVertexListGraph <IBuilder, EquatableEdge <IBuilder> > graph) { return(!graph.IsDirectedAcyclicGraph()); }
private bool HasCycles(IVertexListGraph<IBuilder, EquatableEdge<IBuilder>> graph) { return !graph.IsDirectedAcyclicGraph(); }