Messages from list : cormas@cirad.fr
Choose a topic among the following archives :
neighbourhood bug? (erratum)
Subject: neighbourhood bug? (erratum)
From: Stanislas Boissau (sboissau@fpt.vn)
Date: Thu Oct 02 2003 - 21:56:26 CEST
In my previous email, please read 14 and 13 instead of 15 and
14.
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
Back to home