Class Network2D
- All Implemented Interfaces:
Iterable<Node2D>, Collection<Node2D>, Iterator<Node2D>, List<Node2D>, SequencedCollection<Node2D>
- Direct Known Subclasses:
Network2DGWT
-
Nested Class Summary
Nested classes/interfaces inherited from class Network
Network.LayoutListener, Network.Status -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Vector2DHelper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes.private static final doubleScale factor applied to the nominal 2D accuracy.private static final doubleRadial growth exponent of the deterministic well-mixed phyllotactic seed.protected static final doubleThe inverse size of the baseline 2D universe.protected static final doubleThe inverse squared size of the baseline 2D universe,1/R<sup>2</sup>.protected Path2DThe links in this network.static final doubleThe baseline size of the 2D universe.private final Vector2DHelper variable to store intermediate results when considering the potential energy resulting from the repulsion between nodes.private final Vector2DTemporary storage for the directional vector connecting two nodes.Fields inherited from class Network
accuracy, engine, fLinks, geometry, GOLDEN_ANGLE, HARD_CORE_STIFFNESS, initialAdjust, isRunning, layoutProgress, layoutTimeout, listener, MAX_LINK_COUNT, MIN_DISTANCE, MIN_SCALED_DISTANCE, nLinks, nNodes, nodes, norm, potential, prevAdjust, prevPotential, radius, rng, status, timestampFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNetwork2D(EvoLudo engine, AbstractGeometry geometry) Create a new network in 2D for the given engine and geometry. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdd a directed arc, including its arrowhead, to the link path.private voidaddEdge(int source, int target) Add an undirected edge to the link path.protected doubleattraction(int nodeidx) Calculate the potential energy based on attraction to its neighbours for the node with indexnodeidx.booleanvoidAdd the finishing touches to the graph layout: shift center of mass into origin rescale size of graph find number of linksget(int index) protected doubleGet the effective convergence threshold for the layouting process.getLinks()Get the links in this network for the GUI to draw.inthashCode()voidinitNodes(double pnorm, double nnorm, double unitradius) Generate the initial placement of all nodes.voidGenerate the links for the current configuration of the network.private doublepairDistance(Node2D from, Node2D to, int fromidx, int toidx) Setvecto the directional vector fromfromtotoand return the corresponding center-to-center distance.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.Node2D[]toArray()Methods inherited from class Network
cancelLayout, clear, collectEdges, collectLinks, completeLayout, contains, doLayout, doLayoutPrep, getGeometry, getLayoutTimout, getNLinks, getRadius, getStatus, getTimestamp, getUnitRadius, hasNext, indexOf, isStatus, iterator, lastIndexOf, next, reset, sampleIndices, scaledNodeRadius, scaleRadiusTo, set, setLayoutListener, setLayoutTimout, setRadius, setStatus, shake, size, updateLayoutProgressMethods inherited from class AbstractList
add, add, addAll, listIterator, listIterator, remove, removeRange, subListMethods inherited from class AbstractCollection
addAll, containsAll, isEmpty, 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, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray
-
Field Details
-
FIBONACCI_RADIAL_EXPONENT
private static final double FIBONACCI_RADIAL_EXPONENTRadial growth exponent of the deterministic well-mixed phyllotactic seed. The value0.5reproduces Vogel's area-uniform law, while larger values move the layout towards an Archimedean-looking spiral with a denser center. Convenient values to compare are0.5,0.7,0.8, and1.0.- See Also:
-
links
The links in this network. -
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. -
R
public static final double RThe baseline size of the 2D universe.- See Also:
-
IR
protected static final double IRThe inverse size of the baseline 2D universe. Convenience constant.- See Also:
-
IR2
protected static final double IR2The inverse squared size of the baseline 2D universe,1/R<sup>2</sup>. Convenience constant.- See Also:
-
CONVERGENCE_ACCURACY_SCALE
private static final double CONVERGENCE_ACCURACY_SCALEScale factor applied to the nominal 2D accuracy. The contact-based spring energy is smaller than the former center-distance energy, so 2D layouts use a tighter effective threshold to avoid terminating too early.- See Also:
-
-
Constructor Details
-
Network2D
Create a new network in 2D for the given engine and geometry.- Parameters:
engine- the pacemaker for running the modelgeometry- the structure of the population
-
-
Method Details
-
getLinks
Get the links in this network for the GUI to draw.- Returns:
- the links in this network
-
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. -
getConvergenceAccuracy
protected double getConvergenceAccuracy()Description copied from class:NetworkGet the effective convergence threshold for the layouting process. The base implementation returnsNetwork.accuracy, but subclasses may tighten or relax the criterion when their layout energies use a different natural scale.- Overrides:
getConvergenceAccuracyin classNetwork<Node2D>- Returns:
- the effective convergence threshold
-
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). Implementations may include additional short-range penalties here, for example to discourage overlap between nodes with finite size.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).- Specified by:
attractionin classNetwork<Node2D>- Parameters:
nodeidx- the index of the node to relax- Returns:
- the potential energy of the node
-
pairDistance
Setvecto the directional vector fromfromtotoand return the corresponding center-to-center distance. Coincident nodes are separated by a deterministic fallback direction to keep layouting stable and reproducible.- Parameters:
from- the source nodeto- the target nodefromidx- the index of the source nodetoidx- the index of the target node- Returns:
- the center-to-center distance
-
finishLayout
public void finishLayout()Description copied from class:NetworkAdd the finishing touches to the graph layout:- shift center of mass into origin
- rescale size of graph
- find number of links
- Specified by:
finishLayoutin classNetwork<Node2D>
-
linkNodes
-
addEdge
private void addEdge(int source, int target) Add an undirected edge to the link path.- Parameters:
source- the source node indextarget- the target node index
-
addArc
Add a directed arc, including its arrowhead, to the link path.- Parameters:
source- the source node indextarget- the target node indexlink- helper vector aligned with the arctip- helper vector storing the arrow tip positionarrowsize- the normalized arrow size
-
toArray
- Specified by:
toArrayin interfaceCollection<Node2D>- Specified by:
toArrayin interfaceList<Node2D>- Overrides:
toArrayin classAbstractCollection<Node2D>
-
get
-
equals
-
hashCode
-