Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2012 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2df01576cd9843d34b10 to your computer and use it in GitHub Desktop.
Save anonymous/2df01576cd9843d34b10 to your computer and use it in GitHub Desktop.
(defn find-root [graph ^long node-id]
(let [^Node node (get graph node-id)
parent-id (.parent-id node)]
(if (= parent-id node-id)
[graph node-id]
(let [[graph ^long root-id] (find-root graph parent-id)]
[(update-in graph [node-id] set-parent root-id)
root-id]))))
@jordanlewis
Copy link

Oh, that makes sense. Nevermind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment