-
-
Save anonymous/2df01576cd9843d34b10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, that makes sense. Nevermind!