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.clj11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/clojure/contrib/graph.clj b/src/clojure/contrib/graph.clj
index 47d8e67e..28dc11ca 100644
--- a/src/clojure/contrib/graph.clj
+++ b/src/clojure/contrib/graph.clj
@@ -136,14 +136,17 @@
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?"
+ [g ns]
+ (or (> (count ns) 1)
+ (some ns (get-neighbors g (first ns)))))
+
(defn self-recursive-sets
"Returns, as a sequence of sets, the components of a graph that are
self-recursive."
[g]
- (let [recursive? (fn [ns]
- (or (> (count ns) 1)
- (some ns (get-neighbors g (first ns)))))]
- (filter recursive? (scc g))))
+ (filter (partial recursive-component? g) (scc g)))
;; Dependency Lists