Class AbstractNetwork
Object
AbstractGeometry
AbstractNetwork
- Direct Known Subclasses:
BarabasiAlbertGeometry, KlemmEguiluzGeometry, RandomRegularGeometry, ScalefreeGeometry
Base class for geometries constructed from specific degree distributions.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intNumber of attempts before giving up on constructing the desired graph.(package private) RNGDistributionThe random number generator distribution used for network construction.Fields inherited from class AbstractGeometry
connectivity, EMPTY_LINKS, engine, features, in, isInterspecies, isRegular, isRewired, isSingle, isUndirected, isValid, kin, kout, logger, name, network2D, network3D, out, pAddwire, pRewire, size, specs, type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNetwork(EvoLudo engine) Create a network-backed geometry for the provided engine. -
Method Summary
Modifier and TypeMethodDescriptionprivate intbuildConnectedCore(int[] core, int[] full, int[] degree) Build a connected core of the network first, excluding leaves.private intconnectCorePairs(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.private booleanhandleSingleUnmatched(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.protected booleaninitGeometryDegreeDistr(int[] degree) Utility method to generate a network that realises the requested degree sequence.private int[]Initialize the core array with all node indices.private booleanrewireNeighbourEdge(int nodeA, int nodeB, int[] done, int nDone) Attempt to rewire existing edges so that nodesnodeAandnodeBcan gain additional neighbours without introducing duplicate links.private booleantryConnectOrRewire(int nodea, int nodeb, int[] full, int nFull, int remain) Attempt to connect two nodes, rewiring existing edges if necessary.private intupdateProgressAfterConnect(int[] core, int[] full, int[] degree, int remain, int idxa, int idxb) Update the progress after successfully connecting two nodes.Methods inherited from class AbstractGeometry
addDirected, addEdgeAt, addLinkAt, addUndirected, alloc, check, checkSettings, clearLinksFrom, clearLinksTo, clone, create, create, decodeGeometry, deriveCompetitionGeometry, displaySingle, encodeGeometry, enforceSize, equals, getAddwire, getConnectivity, getEncodeKey, getFeatures, getLabel, getName, getNetwork2D, getNetwork3D, getRewire, getSize, getSpecs, getType, hashCode, init, isConsistent, isGraphConnected, isInterspecies, isLattice, isNeighborOf, isRegular, isRewired, isSingle, isType, isUndirected, isUnique, parse, parse, removeEdgeAt, removeLinkAt, rewire, rewireDirected, rewireEdgeAt, rewireLinkAt, rewireUndirected, setAddwire, setConnectivity, setInterspecies, setName, setNetwork2D, setNetwork3D, setRewire, setSingle, setSize, setType, swapEdges, usage, warn
-
Field Details
-
MAX_TRIALS
static final int MAX_TRIALSNumber of attempts before giving up on constructing the desired graph.- See Also:
-
rng
RNGDistribution rngThe random number generator distribution used for network construction.
-
-
Constructor Details
-
AbstractNetwork
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:
- The
degreearray is expected to be sorted in descending order. - During construction, already connected pairs are rewired via
rewireNeighbourEdge(int, int, int[], int)to avoid multiple edges. - 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:
trueif a matching graph was constructed successfully
- The
-
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 fromfull- the array to store completed nodes indegree- the desired degree sequence- Returns:
- the number of remaining nodes in
coreafter 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 fromfull- the array to store completed nodes indegree- the desired degree sequenceremain- the initial number of nodes incore- Returns:
- the number of remaining nodes in
coreafter 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 connectnodeb- the second node to connectfull- the pool of nodes whose desired degrees are already satisfiednFull- the number of valid entries infullremain- the number of remaining nodes to connect- Returns:
trueif 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 fromfull- the array to store completed nodes indegree- the desired degree sequenceremain- the current number of nodes incoreidxa- the index of the first connected node incoreidxb- the index of the second connected node incore- 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 nodefull- the pool of nodes whose desired degrees are already satisfied- Returns:
trueif reconnection succeeded
-
rewireNeighbourEdge
private boolean rewireNeighbourEdge(int nodeA, int nodeB, int[] done, int nDone) Attempt to rewire existing edges so that nodesnodeAandnodeBcan gain additional neighbours without introducing duplicate links.- Parameters:
nodeA- the first node that still needs neighboursnodeB- the second node that still needs neighboursdone- the pool of nodes whose desired degrees are already satisfiednDone- the number of valid entries indone- Returns:
trueif rewiring succeeded
-