Class Network3D

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

public abstract class Network3D extends Network
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

    • nodes

      protected Node3D[] nodes
      The array with all nodes of this network. This deliberately overrides super.nodes. The two arrays are identical but saves a ton of unnecesary casts.
    • 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:
  • Constructor Details

    • Network3D

      public Network3D(EvoLudo engine, Geometry 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
      Parameters:
      pnorm - the maximal radius of a node
      nnorm - the minimal radius of a node
      unitradius - the reference radius of a node
    • 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
      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
      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).

      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
      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).

      ToDo:

      Prevent nodes from overlapping.
      Specified by:
      attraction in class Network
      Parameters:
      nodeidx - the index of the node to relax
      Returns:
      the potential energy of the node
    • 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
    • toArray

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

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