aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/graph.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/graph.clj')
-rw-r--r--src/clojure/contrib/graph.clj6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/clojure/contrib/graph.clj b/src/clojure/contrib/graph.clj
index 5452340a..8e2eda16 100644
--- a/src/clojure/contrib/graph.clj
+++ b/src/clojure/contrib/graph.clj
@@ -69,7 +69,7 @@
([g n]
(lazy-walk g [n] #{}))
([g ns v]
- (lazy-seq (let [s (seq (remove v ns))
+ (lazy-seq (let [s (seq (drop-while v ns))
n (first s)
ns (rest s)]
(when s
@@ -78,7 +78,9 @@
(defn transitive-closure
"Returns the transitive closure of a graph. The neighbors are lazily computed."
[g]
- (let [nbs (into {} (map (fn [n] [n (delay (lazy-walk g n))]) (:nodes g)))]
+ (let [nns (fn [n]
+ [n (delay (lazy-walk g (get-neighbors g n) #{}))])
+ nbs (into {} (map nns (:nodes g)))]
(struct directed-graph
(:nodes g)
(fn [n] (force (nbs n))))))