Package org.evoludo.simulator
Class Network3D
- All Implemented Interfaces:
Iterable<Node>
,Collection<Node>
,Iterator<Node>
,List<Node>
,SequencedCollection<Node>
- Direct Known Subclasses:
Network3DGWT
Graphical representation of generic population geometries in 3D. A network
corresponds to a (possibly ephemeral) collection and configuration of nodes.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested classes/interfaces inherited from class Network
Network.LayoutListener, Network.Status
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Vector3D
Helper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes.private static final double
The inverse size of the baseline 3D universe.private static final double
The inverse squared size of the baseline 3D universe,1/R<sup>2</sup>
.protected Node3D[]
The array with all nodes of this network.private final Vector3D
Helper variable to store intermediate results when considering the potential energy resulting from the repulsion between nodes.static final double
The baseline size of the 3D universe.private final Vector3D
Temporary storage for the directional vector connecting two nodes.Fields inherited from class Network
accuracy, engine, fLinks, geometry, isRunning, layoutTimeout, listener, MAX_LINK_COUNT, nLinks, nNodes, norm, potential, prevAdjust, prevPotential, radius, rng, status, timestamp
Fields inherited from class AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double
attraction
(int nodeidx) Calculate the potential energy based on attraction to its neighbours for the node with indexnodeidx
.void
Prepare graph for display: shift center of mass into origin rescale size of graph find number of linksget
(int index) void
initNodes
(double pnorm, double nnorm, double unitradius) Generate the initial placement of all nodes.double
relax
(int nodeidx) Relax the potential energy a single node with indexnodeidx
by adjusting its position.double
relax
(int nodeidx, double dt) Relaxes the network node with indexnodeidx
.protected double
repulsion
(int nodeidx) Calculate the potential energy based on repulsion for the node with indexnodeidx
.Node3D[]
toArray()
Methods inherited from class Network
adjustAccuracy, cancelLayout, clear, contains, doLayout, doLayoutPrep, getAccuracy, getGeometry, getLayoutTimout, getRadius, getStatus, hasNext, indexOf, isEmpty, isStatus, iterator, lastIndexOf, linkNodes, next, reset, scaleRadiusTo, set, setAccuracy, setLayoutListener, setLayoutTimout, setRadius, setStatus, shake, size
Methods inherited from class AbstractList
add, add, addAll, equals, hashCode, listIterator, listIterator, remove, removeRange, subList
Methods inherited from class AbstractCollection
addAll, containsAll, remove, removeAll, retainAll, toArray, toString
Methods inherited from interface Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface Iterator
forEachRemaining, remove
Methods inherited from interface List
addAll, addFirst, addLast, containsAll, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray
-
Field Details
-
nodes
The array with all nodes of this network. This deliberately overridessuper.nodes
. The two arrays are identical but saves a ton of unnecesary casts. -
attraction
Helper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes. -
repulsion
Helper variable to store intermediate results when considering the potential energy resulting from the repulsion between nodes. -
vec
Temporary storage for the directional vector connecting two nodes. -
UNIVERSE_RADIUS
public static final double UNIVERSE_RADIUSThe baseline size of the 3D universe.- See Also:
-
IR
private static final double IRThe inverse size of the baseline 3D universe. Convenience constant.- See Also:
-
IR2
private static final double IR2The inverse squared size of the baseline 3D universe,1/R<sup>2</sup>
. Convenience constant.- See Also:
-
-
Constructor Details
-
Network3D
Create a new network in 3D for the given engine and geometry.- Parameters:
engine
- the pacemaker for running the modelgeometry
- the structure of the population
-
-
Method Details
-
initNodes
public void initNodes(double pnorm, double nnorm, double unitradius) Description copied from class:Network
Generate the initial placement of all nodes. The size of nodes scales with their total number of incoming and outgoing links in heterogeneous networks. -
relax
public double relax(int nodeidx) Description copied from class:Network
Relax the potential energy a single node with indexnodeidx
by adjusting its position. The potential energy increases proportional toD
whereD
denotes the distance to its neighbours and decreases proportional to1/D<sup>2</sup>
whereD
refers to the distance from all other nodes. -
relax
public double relax(int nodeidx, double dt) Description copied from class:Network
Relaxes the network node with indexnodeidx
. The attraction and repulsion forces act on the node for a time intervaldt
, which limits the changes in the position of the node. -
repulsion
protected double repulsion(int nodeidx) Description copied from class:Network
Calculate the potential energy based on repulsion for the node with indexnodeidx
. Return the net repulsion (overall direction and magnitude) acting on it inNetwork.repulsion(int)
.Note:
To prevent disjoint parts of a network (and unstructured populations, in particular) to continue to fly apart, the repulsion changes sign, i.e. turns into attraction, once the distance between nodes exceeds the radius of the universe. -
attraction
protected double attraction(int nodeidx) Description copied from class:Network
Calculate the potential energy based on attraction to its neighbours for the node with indexnodeidx
. Return the net attraction (overall direction and magnitude) acting on it inNetwork.attraction(int)
.ToDo:
Prevent nodes from overlapping.- Specified by:
attraction
in classNetwork
- Parameters:
nodeidx
- the index of the node to relax- Returns:
- the potential energy of the node
-
finishLayout
public void finishLayout()Prepare graph for display:- shift center of mass into origin
- rescale size of graph
- find number of links
- Specified by:
finishLayout
in classNetwork
-
toArray
- Specified by:
toArray
in interfaceCollection<Node>
- Specified by:
toArray
in interfaceList<Node>
- Overrides:
toArray
in classAbstractCollection<Node>
-
get
-