public class Network extends Object implements Iterable<Neuron>, Serializable
Neuron
instances and the links
between them.
Although updating a neuron's state is thread-safe, modifying the
network's topology (adding or removing links) is not.Modifier and Type | Class and Description |
---|---|
static class |
Network.NeuronIdentifierComparator
Comparator that prescribes an order of the neurons according
to the increasing order of their identifier.
|
Constructor and Description |
---|
Network(long initialIdentifier,
int featureSize) |
Modifier and Type | Method and Description |
---|---|
void |
addLink(Neuron a,
Neuron b)
Adds a link from neuron
a to neuron b . |
Network |
copy()
Performs a deep copy of this instance.
|
long |
createNeuron(double[] features)
Creates a neuron and assigns it a unique identifier.
|
void |
deleteLink(Neuron a,
Neuron b)
Deletes the link between neurons
a and b . |
void |
deleteNeuron(Neuron neuron)
Deletes a neuron.
|
int |
getFeaturesSize()
Gets the size of the neurons' features set.
|
Collection<Neuron> |
getNeighbours(Iterable<Neuron> neurons)
Retrieves the neurons in the neighbourhood of any neuron in the
neurons list. |
Collection<Neuron> |
getNeighbours(Iterable<Neuron> neurons,
Iterable<Neuron> exclude)
Retrieves the neurons in the neighbourhood of any neuron in the
neurons list. |
Collection<Neuron> |
getNeighbours(Neuron neuron)
Retrieves the neighbours of the given neuron.
|
Collection<Neuron> |
getNeighbours(Neuron neuron,
Iterable<Neuron> exclude)
Retrieves the neighbours of the given neuron.
|
Neuron |
getNeuron(long id)
Retrieves the neuron with the given (unique)
id . |
Collection<Neuron> |
getNeurons(Comparator<Neuron> comparator)
Creates a list of the neurons, sorted in a custom order.
|
Iterator<Neuron> |
iterator() |
public Network(long initialIdentifier, int featureSize)
initialIdentifier
- Identifier for the first neuron that
will be added to this network.featureSize
- Size of the neuron's features.public Network copy()
public Collection<Neuron> getNeurons(Comparator<Neuron> comparator)
comparator
- Comparator
used for sorting the neurons.comparator
.Network.NeuronIdentifierComparator
public long createNeuron(double[] features)
features
- Initial values for the neuron's features.DimensionMismatchException
- if the length of features
is different from the expected size (as set by the
constructor
).public void deleteNeuron(Neuron neuron)
deleted
.neuron
- Neuron to be removed from this network.NoSuchElementException
- if n
does not belong to
this network.public int getFeaturesSize()
public void addLink(Neuron a, Neuron b)
a
to neuron b
.
Note: the link is not bi-directional; if a bi-directional link is
required, an additional call must be made with a
and
b
exchanged in the argument list.a
- Neuron.b
- Neuron.NoSuchElementException
- if the neurons do not exist in the
network.public void deleteLink(Neuron a, Neuron b)
a
and b
.a
- Neuron.b
- Neuron.NoSuchElementException
- if the neurons do not exist in the
network.public Neuron getNeuron(long id)
id
.id
- Identifier.id
.NoSuchElementException
- if the neuron does not exist in the
network.public Collection<Neuron> getNeighbours(Iterable<Neuron> neurons)
neurons
list.neurons
- Neurons for which to retrieve the neighbours.getNeighbours(Iterable,Iterable)
public Collection<Neuron> getNeighbours(Iterable<Neuron> neurons, Iterable<Neuron> exclude)
neurons
list.
The exclude
list allows to retrieve the "concentric"
neighbourhoods by removing the neurons that belong to the inner
"circles".neurons
- Neurons for which to retrieve the neighbours.exclude
- Neurons to exclude from the returned list.
Can be null
.public Collection<Neuron> getNeighbours(Neuron neuron)
neuron
- Neuron for which to retrieve the neighbours.getNeighbours(Neuron,Iterable)
public Collection<Neuron> getNeighbours(Neuron neuron, Iterable<Neuron> exclude)
neuron
- Neuron for which to retrieve the neighbours.exclude
- Neurons to exclude from the returned list.
Can be null
.Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.