Mercurial > projects > dil
changeset 720:74cdbb25c7c8
Using old algo for cycle detection again.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 01 Feb 2008 15:40:32 +0100 |
parents | 8f8c9ab3f3ba |
children | 8955296dd807 |
files | trunk/src/cmd/ImportGraph.d |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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); } -+/