* 20----21----22----23---24
*/
@Test
public void testConcentricNeighbourhood2() {
final FeatureInitializer[] initArray = { init };
final Network net = new NeuronSquareMesh2D(5, true,
5, true,
SquareNeighbourhood.MOORE,
initArray).getNetwork();
Collection<Neuron> neighbours;
Collection<Neuron> exclude = new HashSet<Neuron>();
// Level-1 neighbourhood.
neighbours = net.getNeighbours(net.getNeuron(8));
for (long nId : new long[] { 2, 3, 4, 7, 9, 12, 13, 14 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(8, neighbours.size());
// 1. Add the neuron to the "exclude" list.
exclude.add(net.getNeuron(8));
// 2. Add all neurons from level-1 neighbourhood.
exclude.addAll(neighbours);
// 3. Retrieve level-2 neighbourhood.
neighbours = net.getNeighbours(neighbours, exclude);
for (long nId : new long[] { 1, 6, 11, 16, 17, 18, 19, 15, 10, 5, 0, 20, 24, 23, 22, 21 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(16, neighbours.size());
}