Class AbstractNetwork

Object
AbstractGeometry
AbstractNetwork
Direct Known Subclasses:
BarabasiAlbertGeometry, KlemmEguiluzGeometry, RandomRegularGeometry, ScalefreeGeometry

public abstract class AbstractNetwork extends AbstractGeometry
Base class for geometries constructed from specific degree distributions.
  • Field Details

    • MAX_TRIALS

      static final int MAX_TRIALS
      Number of attempts before giving up on constructing the desired graph.
      See Also:
    • rng

      The random number generator distribution used for network construction.
  • Constructor Details

    • AbstractNetwork

      protected AbstractNetwork(EvoLudo engine)
      Create a network-backed geometry for the provided engine.
      Parameters:
      engine - the EvoLudo pacemaker
  • Method Details

    • initGeometryDegreeDistr

      protected boolean initGeometryDegreeDistr(int[] degree)
      Utility method to generate a network that realises the requested degree sequence.

      Requirements/notes:

      1. The degree array is expected to be sorted in descending order.
      2. During construction, already connected pairs are rewired via rewireNeighbourEdge(int, int, int[], int) to avoid multiple edges.
      3. If a single node remains unmatched, the method attempts to break one of the existing links and reconnect both endpoints to that final node.
      Parameters:
      degree - the degree (outgoing link count) requested for every node
      Returns:
      true if a matching graph was constructed successfully
    • initializeCore

      private int[] initializeCore()
      Initialize the core array with all node indices.
      Returns:
      the initialized core array
    • buildConnectedCore

      private int buildConnectedCore(int[] core, int[] full, int[] degree)
      Build a connected core of the network first, excluding leaves.
      Parameters:
      core - the array of node indices to draw from
      full - the array to store completed nodes in
      degree - the desired degree sequence
      Returns:
      the number of remaining nodes in core after building the connected core
    • connectCorePairs

      private int connectCorePairs(int[] core, int[] full, int[] degree, int remain)
      Connect pairs of nodes from the core until no unmatched nodes remain or no further progress can be made.
      Parameters:
      core - the array of node indices to draw from
      full - the array to store completed nodes in
      degree - the desired degree sequence
      remain - the initial number of nodes in core
      Returns:
      the number of remaining nodes in core after attempting to connect all pairs, or -1 if no progress could be made
    • tryConnectOrRewire

      private boolean tryConnectOrRewire(int nodea, int nodeb, int[] full, int nFull, int remain)
      Attempt to connect two nodes, rewiring existing edges if necessary.
      Parameters:
      nodea - the first node to connect
      nodeb - the second node to connect
      full - the pool of nodes whose desired degrees are already satisfied
      nFull - the number of valid entries in full
      remain - the number of remaining nodes to connect
      Returns:
      true if the connection (or rewiring) succeeded
    • updateProgressAfterConnect

      private int updateProgressAfterConnect(int[] core, int[] full, int[] degree, int remain, int idxa, int idxb)
      Update the progress after successfully connecting two nodes.
      Parameters:
      core - the array of node indices to draw from
      full - the array to store completed nodes in
      degree - the desired degree sequence
      remain - the current number of nodes in core
      idxa - the index of the first connected node in core
      idxb - the index of the second connected node in core
      Returns:
      the updated number of nodes remaining in core
    • handleSingleUnmatched

      private boolean handleSingleUnmatched(int nodea, int[] full)
      Handle the case where a single node remains unmatched by breaking an existing edge and reconnecting both endpoints to that final node.
      Parameters:
      nodea - the single unmatched node
      full - the pool of nodes whose desired degrees are already satisfied
      Returns:
      true if reconnection succeeded
    • rewireNeighbourEdge

      private boolean rewireNeighbourEdge(int nodeA, int nodeB, int[] done, int nDone)
      Attempt to rewire existing edges so that nodes nodeA and nodeB can gain additional neighbours without introducing duplicate links.
      Parameters:
      nodeA - the first node that still needs neighbours
      nodeB - the second node that still needs neighbours
      done - the pool of nodes whose desired degrees are already satisfied
      nDone - the number of valid entries in done
      Returns:
      true if rewiring succeeded