aysylu / loom

Graph library for Clojure. Mailing list https://groups.google.com/forum/#!forum/loom-clj
http://aysy.lu/loom/
887 stars 108 forks source link

(scc ...) doesn't compute the correct components in some cases #6

Closed jszakmeister closed 11 years ago

jszakmeister commented 11 years ago

I managed to whittle this down to a test case that fails to compute the correct components, but haven't gotten to the point where I understand what it broken just yet. Here's the test case:

(defn scc-is-busted []
  (let [g (digraph [1 5] [2 4] [3 1] [3 2] [3 6]
                   [4 10] [5 3] [6 1] [6 10] [7 8]
                   [8 9] [8 11] [9 3] [9 5] [9 7]
                   [10 2] [11 2] [11 4])
        components (set (map set (scc g)))
        expected   #{ #{2 4 10} #{1 3 5 6} #{11} #{7 8 9}}]
    (prn components)
    (if (not= expected components)
      (throw (RuntimeException. "scc did not compute the correct components")))))

There should be 4 strongly connected components, but scc is only returning 2, and they're wrong.

aysylu commented 11 years ago

This has been fixed with the pull request #7. Thanks!