graph reduction in Clojure