# HG changeset patch # User Aziz K?ksal # Date 1201876832 -3600 # Node ID 74cdbb25c7c804c330149bce056d1fa8fba4108a # Parent 8f8c9ab3f3baddf1d93652471b57852cdc640336 Using old algo for cycle detection again. diff -r 8f8c9ab3f3ba -r 74cdbb25c7c8 trunk/src/cmd/ImportGraph.d --- a/trunk/src/cmd/ImportGraph.d Fri Feb 01 15:05:26 2008 +0100 +++ b/trunk/src/cmd/ImportGraph.d Fri Feb 01 15:40:32 2008 +0100 @@ -57,8 +57,9 @@ { // Cycles could also be detected in the GraphBuilder, // but having the code here makes things much clearer. + // Commented out because this algorithm doesn't work. // Returns true if the vertex is in status Visiting. - bool visit(Vertex vertex) + /+bool visit(Vertex vertex) { switch (vertex.status) { @@ -79,11 +80,14 @@ return false; // return (vertex.status == Vertex.Status.Visiting); } // Start visiting vertices. - visit(vertices[0]); + visit(vertices[0]);+/ - foreach (edge; edges) - if (edge.from.isCyclic && edge.to.isCyclic) - edge.isCyclic = true; + //foreach (edge; edges) + // if (edge.from.isCyclic && edge.to.isCyclic) + // edge.isCyclic = true; + + // Use functioning algorithm. + analyzeGraph(vertices, edges); } } @@ -335,10 +339,10 @@ Stdout("}\n"); } -/+ // This is the old algorithm that was used to detect cycles in a directed graph. void analyzeGraph(Vertex[] vertices_init, Edge[] edges) { + edges = edges.dup; void recursive(Vertex[] vertices) { foreach (idx, vertex; vertices) @@ -407,4 +411,3 @@ } recursive(vertices_init); } -+/