There are many ways one could model a tree/graph:
;; collection of edges
[[:a :b] [:b :c] [:b :d] [:c :e] [:d :e]]
;; adjacency list
{:a [:b] :b [:c :d] :c [:e] :d [:e]}
If you're looking for a pre-made solution, the loom graph library
(https://github.com/jkk/loom) may work:
(ns example
(:use [loom.graph :only [digraph]]
[loom.alg :only [shortest-path]]))
(def dg (digraph {:a [:b] :b [:c :d] :c [:e] :d [:e]}))
(shortest-path dg :a :e)
; => (:a :b :c :e)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en