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 Vector3DHelper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes.private static final doubleThe inverse size of the baseline 3D universe.private static final doubleThe 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 Vector3DHelper variable to store intermediate results when considering the potential energy resulting from the repulsion between nodes.static final doubleThe baseline size of the 3D universe.private final Vector3DTemporary 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, timestampFields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doubleattraction(int nodeidx) Calculate the potential energy based on attraction to its neighbours for the node with indexnodeidx.voidPrepare graph for display: shift center of mass into origin rescale size of graph find number of linksget(int index) voidinitNodes(double pnorm, double nnorm, double unitradius) Generate the initial placement of all nodes.doublerelax(int nodeidx) Relax the potential energy a single node with indexnodeidxby adjusting its position.doublerelax(int nodeidx, double dt) Relaxes the network node with indexnodeidx.protected doublerepulsion(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, sizeMethods inherited from class AbstractList
add, add, addAll, equals, hashCode, listIterator, listIterator, remove, removeRange, subListMethods inherited from class AbstractCollection
addAll, containsAll, remove, removeAll, retainAll, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface Iterator
forEachRemaining, removeMethods 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:NetworkGenerate 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:NetworkRelax the potential energy a single node with indexnodeidxby adjusting its position. The potential energy increases proportional toDwhereDdenotes the distance to its neighbours and decreases proportional to1/D<sup>2</sup>whereDrefers to the distance from all other nodes. -
relax
public double relax(int nodeidx, double dt) Description copied from class:NetworkRelaxes 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:NetworkCalculate 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:NetworkCalculate 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:
attractionin 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:
finishLayoutin classNetwork
-
toArray
- Specified by:
toArrayin interfaceCollection<Node>- Specified by:
toArrayin interfaceList<Node>- Overrides:
toArrayin classAbstractCollection<Node>
-
get
-