diff options
author | Jeffrey Straszheim <straszheimjeffrey@gmail.com> | 2009-02-24 00:58:32 +0000 |
---|---|---|
committer | Jeffrey Straszheim <straszheimjeffrey@gmail.com> | 2009-02-24 00:58:32 +0000 |
commit | 432372af9773809955e4ce5fcfa2d140bcbbe1d7 (patch) | |
tree | a4744739dc17519b2dc17099b2672756629f6333 | |
parent | f39ba0971524b94189b3bcf007170d5a7e9e6643 (diff) |
Began graph module
-rw-r--r-- | src/clojure/contrib/graph.clj | 5 | ||||
-rw-r--r-- | src/clojure/contrib/test_contrib/test_graph.clj | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/clojure/contrib/graph.clj b/src/clojure/contrib/graph.clj index 5890a8f8..34a3454e 100644 --- a/src/clojure/contrib/graph.clj +++ b/src/clojure/contrib/graph.clj @@ -56,8 +56,7 @@ ) (defn- post-ordered-visit - "Starting at node n, return a sequence of a post-ordered walk of the - graph." + "Starting at node n, perform a post-ordered walk." [g n [visited acc :as state]] (if (visited n) state @@ -84,7 +83,7 @@ acc (let [[nv comp] (post-ordered-visit rev (first stack) - [visited []]) + [visited #{}]) ns (remove nv stack)] (recur ns nv (conj acc comp)))))] (step po #{} []))) diff --git a/src/clojure/contrib/test_contrib/test_graph.clj b/src/clojure/contrib/test_contrib/test_graph.clj index 7a92a734..093462b8 100644 --- a/src/clojure/contrib/test_contrib/test_graph.clj +++ b/src/clojure/contrib/test_contrib/test_graph.clj @@ -60,7 +60,7 @@ (deftest test-scc - (is (= (map set (scc test-graph-2)) + (is (= (scc test-graph-2) [#{8 9} #{7} #{6} #{5} #{0 1 2 3 4}])) (is (empty? (scc empty-graph)))) |