aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/graph.clj
diff options
context:
space:
mode:
authorJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-26 02:47:28 +0000
committerJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-26 02:47:28 +0000
commit9601e6585de31f60e082197e7ce85dcbc82ca0bb (patch)
treed1804bc78d0eb1d00c030f3474d412fcc022bd00 /src/clojure/contrib/graph.clj
parentb62386e14b447326b43c13b4f94a139a77b4a32e (diff)
More tweaks
Diffstat (limited to 'src/clojure/contrib/graph.clj')
-rw-r--r--src/clojure/contrib/graph.clj23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/clojure/contrib/graph.clj b/src/clojure/contrib/graph.clj
index 80e1d80f..5452340a 100644
--- a/src/clojure/contrib/graph.clj
+++ b/src/clojure/contrib/graph.clj
@@ -124,17 +124,18 @@
Each node in the new graph will be a set of nodes from the old.
These sets are the strongly connected components. Each edge will
be the union of the corresponding edges of the prior graph."
- [g]
- (let [sccs (scc g)
- find-node-set (fn [n]
- (some #(if (% n) % nil) sccs))
- find-neighbors (fn [ns]
- (let [nbs1 (map (partial get-neighbors g) ns)
- nbs2 (map set nbs1)
- nbs3 (apply union nbs2)]
- (set (map find-node-set nbs3))))
- nm (into {} (map (fn [ns] [ns (find-neighbors ns)]) sccs))]
- (struct directed-graph (set sccs) nm)))
+ ([g]
+ (component-graph g (scc g)))
+ ([g sccs]
+ (let [find-node-set (fn [n]
+ (some #(if (% n) % nil) sccs))
+ find-neighbors (fn [ns]
+ (let [nbs1 (map (partial get-neighbors g) ns)
+ nbs2 (map set nbs1)
+ nbs3 (apply union nbs2)]
+ (set (map find-node-set nbs3))))
+ nm (into {} (map (fn [ns] [ns (find-neighbors ns)]) sccs))]
+ (struct directed-graph (set sccs) nm))))
(defn recursive-component?
"Is the component (recieved from scc) self recursive?"