Re: Python recursive tree, linked list thingy

2012-03-08 Thread Wanderer
On Mar 7, 3:27 pm, Ian Kelly wrote: > On Wed, Mar 7, 2012 at 1:03 PM, Ian Kelly wrote: > > A set of defective pixels would be the probable choice, since it > > offers efficient membership testing. > > Some actual code, using a recursive generator: > > def get_cluster(defective, pixel): >     yiel

Re: Python recursive tree, linked list thingy

2012-03-08 Thread Robert Kern
On 3/8/12 9:12 AM, Enrico Franchi wrote: Wanderer 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:

Re: Python recursive tree, linked list thingy

2012-03-08 Thread Enrico Franchi
Wanderer 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

Re: Python recursive tree, linked list thingy

2012-03-07 Thread Ian Kelly
On Wed, Mar 7, 2012 at 1:03 PM, Ian Kelly wrote: > A set of defective pixels would be the probable choice, since it > offers efficient membership testing. Some actual code, using a recursive generator: def get_cluster(defective, pixel): yield pixel (row, column) = pixel for adjacent

Re: Python recursive tree, linked list thingy

2012-03-07 Thread Alexander Blinne
Am 07.03.2012 20:49, schrieb Wanderer: I have a list of defective CCD pixels and I need to find clusters where a cluster is a group of adjacent defective pixels. This seems to me to be a classic linked list tree search.I take a pixel from the defective list and check if an adjacent pixel is in th

Re: Python recursive tree, linked list thingy

2012-03-07 Thread MRAB
On 07/03/2012 19:49, Wanderer wrote: I have a list of defective CCD pixels and I need to find clusters where a cluster is a group of adjacent defective pixels. This seems to me to be a classic linked list tree search.I take a pixel from the defective list and check if an adjacent pixel is in the

Re: Python recursive tree, linked list thingy

2012-03-07 Thread Ian Kelly
On Wed, Mar 7, 2012 at 12:49 PM, Wanderer wrote: > I have a list of defective CCD pixels and I need to find clusters > where a cluster is a group of adjacent defective pixels. This seems to > me to be a classic linked list tree search.I take a pixel from the > defective list and check if an adjace