Python recursive tree, linked list thingy

Enrico Franchi riko at
Thu Mar 8 10:12:16 CET 2012

Wanderer <wanderer at> wrote:

>  How
> do you handle this sort of thing in Python?

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

Depending on the exact nature of your problem, you may also want to
check out the Hoshen-Kopelman Algorithm. Although the algorithm itself
is rather efficient, it was born in the context of percolation, that is
to say with the assumption that the "broken" (or colored) cells are much
more likely than in your context.


More information about the Python-list mailing list