aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-28 06:04:49 +0000
committerJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-28 06:04:49 +0000
commitd7e521dceaa63a3da50c531e22e1ec319150c619 (patch)
treee27e7bd0adf6332404ef20daec48abe78a851862
parentf3e13539c0e557ff44f54a7b73373909dca91129 (diff)
Added comment to transitive-closure
-rw-r--r--src/clojure/contrib/graph.clj8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/clojure/contrib/graph.clj b/src/clojure/contrib/graph.clj
index 8e2eda16..f3ca4f3d 100644
--- a/src/clojure/contrib/graph.clj
+++ b/src/clojure/contrib/graph.clj
@@ -76,7 +76,13 @@
(cons n (lazy-walk g (concat (get-neighbors g n) ns) (conj v n))))))))
(defn transitive-closure
- "Returns the transitive closure of a graph. The neighbors are lazily computed."
+ "Returns the transitive closure of a graph. The neighbors are lazily computed.
+
+ Note: some version of this algorithm return all edges a->a
+ regardless of whether such loops exist in the original graph. This
+ version does not. Loops will be included only if produced by
+ cycles in the graph. If you have code that depends on such
+ behavior, call (-> g transitive-closure add-loops)"
[g]
(let [nns (fn [n]
[n (delay (lazy-walk g (get-neighbors g n) #{}))])