Class Network2D

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

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

    • nodes

      protected Node2D[] 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 Vector2D attraction
      Helper variable to store intermediate results when considering the potential energy resulting from the attraction between neighbouring nodes.
    • repulsion

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

      private final Vector2D vec
      Temporary storage for the directional vector connecting two nodes.
    • R

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

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

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

    • Network2D

      public Network2D(EvoLudo engine, Geometry geometry)
      Create a new network in 2D for the given engine and geometry.
      Parameters:
      engine - the pacemaker for running the model
      geometry - the structure of the population
  • Method Details

    • reset

      public void reset()
      Description copied from class: Network
      Reset the network (discard any existing layouts).
      Overrides:
      reset in class Network
    • getLinks

      public Path2D 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: 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()
      Description copied from class: Network
      Add the finishing touches to the graph layout:
      1. shift center of mass into origin
      2. rescale size of graph
      3. find number of links
      Specified by:
      finishLayout in class Network
    • linkNodes

      public void linkNodes()
      Description copied from class: Network
      Generate the links for the current configuration of the network.
      Specified by:
      linkNodes in class Network
    • toArray

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

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