Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

neighbourhood bug?

New Message Reply Date view Thread view Subject view Author view

Subject: neighbourhood bug?
From: Stanislas Boissau (sboissau@fpt.vn)
Date: Thu Oct 02 2003 - 21:50:25 CEST

Hi all,
I think I found a bug in the recursiveNeighbourhood: n method. I just had a line at the method to correct it
(newVoisins := newVoisins reject: [ :i | ensemble includes: i ]).
If you do not had this line, and for n >= 2, the method is including some cells twice.
For example for a neighbourhood of 4 and n = 2 it was giving back a collection of 15 cells instead of 14

recursiveNeighbourhood: n
        | ensemble peripherie newVoisins |
        ensemble := OrderedCollection new.
        ensemble add: self.
        peripherie := OrderedCollection new.
        peripherie add: self.
        n timesRepeat:
                        [newVoisins := OrderedCollection new. 
                        peripherie do: [:p | p neighbourhood do:[:v| (newVoisins includes: v) ifFalse: [newVoisins add: v]]].
                        newVoisins := newVoisins reject: [ :i | ensemble includes: i ].
                        peripherie := newVoisins reject: [ :i | ensemble includes: i ].
                        ensemble addAll: newVoisins].
        ^ensemble

Stan

New Message Reply Date view Thread view Subject view Author view
 

Back to home