Python recursive tree, linked list thingy

Robert Kern robert.kern at gmail.com
Thu Mar 8 11:40:08 CET 2012


On 3/8/12 9:12 AM, Enrico Franchi wrote:
> Wanderer<wanderer at 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




More information about the Python-list mailing list