On 3/8/12 9:12 AM, Enrico Franchi wrote:
Wanderer<wande...@dialup4less.com>  wrote:

  How
do you handle this sort of thing in Python?

I believe that the best thing to do is a Union-Find algorithm.

Another term this problem is finding the "connected components". Here is some code from Stefan van der Walt for this:

  http://mentat.za.net/source/connected_components.tar.bz2
  http://mentat.za.net/cgi-bin/hgwebdir.cgi/ccomp

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to