Depending on your needs, you may instead want to consider converting your
data to a graph data structure, rather than a tree.  The benefits are that
it will deal properly with cycles, multiple components, or diverging and
re-converging paths.  Then in graph form you will be able to run a large
library of graph algorithms on it to find shortest paths between nodes, etc.

https://github.com/Engelberg/ubergraph is one way to build a graph in
Clojure.  The example input you gave is known as an adjacency map, and is
one of the kinds of inputs accepted by the constructor.

So, for example, you can simply do (uber/digraph answer24).


On Mon, Jan 30, 2017 at 5:46 AM, Robert Aaron Zawiasa <bobo.li...@gmail.com>
wrote:

> I got a perfect answer from @moxaj on Clojurians Slack:
> https://clojurians.slack.com/files/moxaj/F3Y6J1X0S/-.clj
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to