Network evolution (simulation component)

NOTE: This component is currently non-functional.

network_evolution_sim module

class defSim.network_evolution_sim.network_evolution_sim.NetworkModifier(**kwargs)

Bases: abc.ABC

The NetworkModifier changes the structure of the network. It can build or remove edges based on how agents are connected and what attributes they have.

__init__(**kwargs)

Initialize self. See help(type(self)) for accurate signature.

abstract rewire_network(network: networkx.classes.graph.Graph, **kwargs)

Creates new connections or deletes existing ones. Can be used to implement coevolution of networks and model selection processes.

Parameters

network – The network that will be modified.

defSim.network_evolution_sim.network_evolution_sim.rewire_network(network: networkx.classes.graph.Graph, realization: str, **kwargs)

This function works as a factory method for the NetworkModifier component. It calls the rewire_network method of a specific implementation of the AttributesInitializer and passes to it the kwargs dictionary.

Parameters
  • network – The network that will be modified.

  • realization – The specific NetworkModifier that shall be used to initialize the attributes. Options are “maslov_sneppen”, ..

  • kwargs – The parameter dictionary with all optional parameters.

MaslovSneppenModifier

class defSim.network_evolution_sim.MaslovSneppenModifier.MaslovSneppenModifier(rewiring_prop: Optional[float] = None, rewiring_exact: Optional[int] = None)

Bases: defSim.network_evolution_sim.network_evolution_sim.NetworkModifier

__init__(rewiring_prop: Optional[float] = None, rewiring_exact: Optional[int] = None)

Initialize self. See help(type(self)) for accurate signature.

rewire_network(network: networkx.classes.graph.Graph, rewiring_prop: Optional[float] = None, rewiring_exact=None, **kwargs)

This method executes Maslov Sneppen rewiring [MaslovSneppen2002]. Until a given proportion of the network edges is rewired, the algorithm will pick two edges at random, remove them, and construct an edge between a different combination of nodes that have just lost an edge. Effectively, this introduces randomization of network structure, while leaving the degree distribution unchanged. Because the parameter rewiring_prop functions as a threshold for number of rewiring iterations that need to be executed, it can exceed 1. Actually, to achieve a random network starting from a network with structure, the rewiring proportion should exceed 1.

Parameters
  • network – NetworkX Graph object

  • rewiring_prop – A threshold for the minimum proportion of edges in the graph object that need to be rewired. Sampling these edges happens with replacement, so rewiring_prop may exceed 1.

  • rewiring_exact – The exact number of edges to rewire. One of rewiring_prop or rewiring_exact must be set. If both are set, rewiring_exact takes precedence.

Returns

Does not return the network. The network is modified in place.

NewTiesModifier

class defSim.network_evolution_sim.NewTiesModifier.NewTiesModifier(new_ties_probability: Optional[float] = None)

Bases: defSim.network_evolution_sim.network_evolution_sim.NetworkModifier

__init__(new_ties_probability: Optional[float] = None)

Initialize self. See help(type(self)) for accurate signature.

rewire_network(network: networkx.classes.graph.Graph, new_ties_probability: Optional[float] = None, **kwargs)

This function finds all previously unconnected agents in the network and connects them with a given probability.

Parameters
  • network – NetworkX Graph object

  • new_ties_probability – Probability to create new tie between each pair of previously unconnected agents.

The network is modified in place. :returns: Number of edges added.

References

MaslovSneppen2002

Maslov, S., & Sneppen, K. (2002). Specificity and stability in topology of protein networks. Science, 296(May), 910–913. https://doi.org/10.1126/science.1065103