aysylu / loom

Graph library for Clojure. Mailing list https://groups.google.com/forum/#!forum/loom-clj
http://aysy.lu/loom/
887 stars 108 forks source link

derive graphs from existing graphs using maps and filters #71

Closed monora closed 8 years ago

monora commented 9 years ago

Based on fly-graph we can easily create graphs from an existing graph:

- by projection using map
- by filtering nodes and edges
- filtering only edges

To test these functions the following predicates for graphs implemented by danshapero were added to alg.clj:

- subgraph?
- eql?
- isomorphism?

I implemented some functions to derive graphs from existing graphs. I am using these in an experimental library to analyse java code dependencies. See https://bitbucket.org/monora/cljdepend

Example snippets from there:

;; Analyse ant
(def g (jgraph-from-m2 "ant/ant/1.6.5/ant-1.6.5.jar"))
(view (package-graph g))
(view (nodes-filtered-by #(re-find #"^org.apache.ant..(taskdefs|tar)" %) (package-graph g)))
(view (pkg-surroundings g #"cvslib$"))

;; Analyse clojure
(def g (jgraph-from-m2 "org/clojure/clojure/1.6.0/clojure-1.6.0.jar"))
(view (nodes-filtered-by #(re-find #"^clojure" %) (package-graph g)))
aysylu commented 9 years ago

Could you please merge conflicts when you get a chance? Hopefully, it'll be pretty straightforward. Thanks!

aysylu commented 9 years ago

One more thing: if you don't mind moving the description from #70 to this PR, that'd be great. It has some great usage examples.:)

monora commented 9 years ago

Thanks for the thorough review. The last commits should hopefully fix these issues. I am looking forward for your comments.

aysylu commented 8 years ago

This looks good. Thanks for your contribution!