NeuronString implements Serializable { public Network getNetwork() { return network; } NeuronString(boolean wrap,
                 double[][] featuresList);  NeuronString(int num,
                        boolean wrap,
                        FeatureInitializer[] featureInit); Network getNetwork(); int getSize(); double[] getFeatures(int i);  }
@Test public void testSegmentNetwork() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronString(4, false, initArray).getNetwork(); Collection<Neuron> neighbours; neighbours = net.getNeighbours(net.getNeuron(0)); for (long nId : new long[] { 1 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(1, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(1)); for (long nId : new long[] { 0, 2 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(2)); for (long nId : new long[] { 1, 3 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(3)); for (long nId : new long[] { 2 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(1, neighbours.size()); }
@Test public void testCircleNetwork() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronString(4, true, initArray).getNetwork(); Collection<Neuron> neighbours; neighbours = net.getNeighbours(net.getNeuron(0)); for (long nId : new long[] { 1, 3 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(1)); for (long nId : new long[] { 0, 2 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(2)); for (long nId : new long[] { 1, 3 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); neighbours = net.getNeighbours(net.getNeuron(3)); for (long nId : new long[] { 0, 2 }) { Assert.assertTrue(neighbours.contains(net.getNeuron(nId))); } Assert.assertEquals(2, neighbours.size()); }
@Test public void testGetNeighboursWithExclude() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronString(5, true, initArray).getNetwork(); final Collection<Neuron> exclude = new ArrayList<Neuron>(); exclude.add(net.getNeuron(1)); final Collection<Neuron> neighbours = net.getNeighbours(net.getNeuron(0), exclude); Assert.assertTrue(neighbours.contains(net.getNeuron(4))); Assert.assertEquals(1, neighbours.size()); }