* 6-----7-----8
*/
@Test
public void test3x3CylinderNetwork() {
final FeatureInitializer[] initArray = { init };
final Network net = new NeuronSquareMesh2D(3, false,
3, true,
SquareNeighbourhood.MOORE,
initArray).getNetwork();
Collection<Neuron> neighbours;
// Neuron 0.
neighbours = net.getNeighbours(net.getNeuron(0));
for (long nId : new long[] { 1, 2, 3, 4, 5}) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
// Neuron 1.
neighbours = net.getNeighbours(net.getNeuron(1));
for (long nId : new long[] { 0, 2, 3, 4, 5 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
// Neuron 2.
neighbours = net.getNeighbours(net.getNeuron(2));
for (long nId : new long[] { 0, 1, 3, 4, 5 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
// Neuron 3.
neighbours = net.getNeighbours(net.getNeuron(3));
for (long nId : new long[] { 0, 1, 2, 4, 5, 6, 7, 8 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(8, neighbours.size());
// Neuron 4.
neighbours = net.getNeighbours(net.getNeuron(4));
for (long nId : new long[] { 0, 1, 2, 3, 5, 6, 7, 8 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(8, neighbours.size());
// Neuron 5.
neighbours = net.getNeighbours(net.getNeuron(5));
for (long nId : new long[] { 0, 1, 2, 3, 4, 6, 7, 8 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(8, neighbours.size());
// Neuron 6.
neighbours = net.getNeighbours(net.getNeuron(6));
for (long nId : new long[] { 3, 4, 5, 7, 8 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
// Neuron 7.
neighbours = net.getNeighbours(net.getNeuron(7));
for (long nId : new long[] { 3, 4, 5, 6, 8 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
// Neuron 8.
neighbours = net.getNeighbours(net.getNeuron(8));
for (long nId : new long[] { 3, 4, 5, 6, 7 }) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
// Ensures that no other neurons is in the neihbourhood set.
Assert.assertEquals(5, neighbours.size());
}