Class Network3D

All Implemented Interfaces:
Iterable<Node3D>, Collection<Node3D>, Iterator<Node3D>, List<Node3D>, SequencedCollection<Node3D>
Direct Known Subclasses:
Network3DGWT

public abstract class Network3D extends Network<Node3D>
Graphical representation of generic population geometries in 3D. A network corresponds to a (possibly ephemeral) collection and configuration of nodes.
Author:
Christoph Hauert
  • Field Details

    • SHELL_THICKNESS_SCALE

      private static final double SHELL_THICKNESS_SCALE
      Fraction of the nominal nearest-neighbour spacing used as radial shell thickness. Values below one create more shells than a strict packing estimate, which makes the seed look more organic while still filling the volume.
      See Also:
    • attraction

      private final Vector3D attraction
      Helper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes.
    • repulsion

      private final Vector3D repulsion
      Helper variable to store intermediate results when considering the potential energy resulting from the repulsion between nodes.
    • vec

      private final Vector3D vec
      Temporary storage for the directional vector connecting two nodes.
    • UNIVERSE_RADIUS

      public static final double UNIVERSE_RADIUS
      The baseline size of the 3D universe.
      See Also:
    • IR

      private static final double IR
      The inverse size of the baseline 3D universe. Convenience constant.
      See Also:
    • IR2

      private static final double IR2
      The inverse squared size of the baseline 3D universe, 1/R<sup>2</sup>. Convenience constant.
      See Also:
    • MIN_DISTANCE2

      private static final double MIN_DISTANCE2
      Smallest admissible squared center-to-center distance during layout calculations.
      See Also:
  • Constructor Details

    • Network3D

      protected Network3D(EvoLudo engine, AbstractGeometry geometry)
      Create a new network in 3D for the given engine and geometry.
      Parameters:
      engine - the pacemaker for running the model
      geometry - 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.
      Specified by:
      initNodes in class Network<Node3D>
      Parameters:
      pnorm - the maximal radius of a node
      nnorm - the minimal radius of a node
      unitradius - the reference radius of a node
    • createFibonacciShells

      private static ArrayList<double[]> createFibonacciShells(int nNodes)
      Create a deterministic ball composed of concentric phyllotactic shells. Node zero is kept at the origin, while the remaining nodes are distributed over spherical shells with populations proportional to shell volume.
      Parameters:
      nNodes - the number of nodes to distribute
      Returns:
      the shell positions sorted from the center to the boundary
    • nodesPerShell

      private static int[] nodesPerShell(double maxR, int nShells, int sNodes)
      Apportion the non-central nodes across concentric shells in proportion to shell volume using the largest-remainder method.
      Parameters:
      maxR - the radius of the seed ball
      nShells - the number of shells
      sNodes - the number of nodes on shells
      Returns:
      the number of nodes placed on each shell
    • volumeMeanRadius

      private static double volumeMeanRadius(double iR, double oR)
      Compute the radius that best represents the shell volume between two boundaries. This uses the radius averaged with respect to volume density.
      Parameters:
      iR - the inner shell boundary
      oR - the outer shell boundary
      Returns:
      the representative shell radius
    • relax

      public double relax(int nodeidx)
      Description copied from class: Network
      Relax the potential energy a single node with index nodeidx by adjusting its position. The potential energy increases proportional to D where D denotes the distance to its neighbours and decreases proportional to 1/D<sup>2</sup> where D refers to the distance from all other nodes.
      Specified by:
      relax in class Network<Node3D>
      Parameters:
      nodeidx - the index of the node to relax
      Returns:
      the change in potential energy
    • relax

      public double relax(int nodeidx, double dt)
      Description copied from class: Network
      Relaxes the network node with index nodeidx. The attraction and repulsion forces act on the node for a time interval dt, which limits the changes in the position of the node.
      Specified by:
      relax in class Network<Node3D>
      Parameters:
      nodeidx - the index of the node to relax
      dt - the time interval
      Returns:
      the change in potential energy
      See Also:
    • repulsion

      protected double repulsion(int nodeidx)
      Description copied from class: Network
      Calculate the potential energy based on repulsion for the node with index nodeidx. Return the net repulsion (overall direction and magnitude) acting on it in Network.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.
      Specified by:
      repulsion in class Network<Node3D>
      Parameters:
      nodeidx - the index of the node to relax
      Returns:
      the potential energy of the node
    • 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 index nodeidx. Return the net attraction (overall direction and magnitude) acting on it in Network.attraction(int).
      Specified by:
      attraction in class Network<Node3D>
      Parameters:
      nodeidx - the index of the node to relax
      Returns:
      the potential energy of the node
    • pairDistance

      private double pairDistance(Node3D from, Node3D to, int fromidx, int toidx)
      Set vec to the directional vector from from to to and 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 node
      to - the target node
      fromidx - the index of the source node
      toidx - the index of the target node
      Returns:
      the center-to-center distance
    • fractional

      private static double fractional(double value)
      Return the fractional part of value.
      Parameters:
      value - the value to reduce to its fractional part
      Returns:
      the fractional part in the interval [0,1)
    • finishLayout

      public void finishLayout()
      Prepare graph for display:
      1. shift center of mass into origin
      2. rescale size of graph
      3. find number of links
      Specified by:
      finishLayout in class Network<Node3D>
    • toArray

      public Node3D[] toArray()
      Specified by:
      toArray in interface Collection<Node3D>
      Specified by:
      toArray in interface List<Node3D>
      Overrides:
      toArray in class AbstractCollection<Node3D>
    • get

      public Node3D get(int index)
      Specified by:
      get in interface List<Node3D>
      Specified by:
      get in class AbstractList<Node3D>
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<Node3D>
      Specified by:
      equals in interface List<Node3D>
      Overrides:
      equals in class Network<Node3D>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<Node3D>
      Specified by:
      hashCode in interface List<Node3D>
      Overrides:
      hashCode in class Network<Node3D>