Skip to content

Cascades of failures in interdependent networks

The cascade of failures of Buldyrev between two interdependent networks.

  • Class: InterdependentNetworkCascadeSystem
  • Import: from skcomplex.systems.mathematics.networks import InterdependentNetworkCascadeSystem
  • Field: mathematics/networks
  • Topics: network, interdependent networks, cascade, percolation, multilayer
  • References:
    • Buldyrev et al. 2010
    • Artime et al. 2025

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.mathematics.networks import InterdependentNetworkCascadeSystem

trajectory = InterdependentNetworkCascadeSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
n_nodes 2000
mean_degree 4.0
p 0.8
random_state 0
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time discrete
Space network
Laws update
Randomness deterministic
Domains boolean
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class InterdependentNetworkCascadeSystem(BaseSystem):
    """The cascade of failures of Buldyrev between two interdependent networks.

    The cascade is that of Buldyrev et al., and the nodes of the networks depend on each other.

    Two Erdős-Rényi networks of the mean degree `mean_degree` share their nodes, every node of one depending on the node
    of the same index in the other, so a node is one pair of dependent nodes. An attack leaves every node functional
    with probability `p`. At even steps the nodes outside the giant component of the functional nodes of the first
    network fail, and at odd steps those outside that of the second network, until the cascade stops at the mutual giant
    component (Buldyrev et al. 2010, as Artime et al. 2025, section 5, Eqs. 9 to 11, review it). Its share `S` solves `S
    = p (1 - exp(-k S))²`, which has a solution above 0 only for `p` above `2.4554 / k`, where the networks collapse at
    once in a discontinuous transition. The system has the functional nodes `nodes.active` over the graph of the first
    network and the layer `dependent` of the second.

    Args:
        n_nodes:
            The number of nodes of every network.

        mean_degree:
            The mean degree `k` of every network.

        p:
            The share of nodes the attack leaves functional.

        random_state:
            The seed or generator of the networks and the attack.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.mathematics.networks import InterdependentNetworkCascadeSystem
        >>> system = InterdependentNetworkCascadeSystem(200, p=0.3).prepare()
        >>> int(system.simulate(until=20).get_values('nodes.active')[-1].sum())
        0
    """

    field = 'mathematics/networks'
    topics = ('network', 'interdependent networks', 'cascade', 'percolation', 'multilayer')
    references = ('Buldyrev et al. 2010', 'Artime et al. 2025')
    until = 40

    def __init__(
        self,
        n_nodes: int = 2000,
        *,
        mean_degree: float = 4.0,
        p: float = 0.8,
        random_state: int | np.random.Generator | None = 0,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.n_nodes = n_nodes
        self.mean_degree = mean_degree
        self.p = p
        self.random_state = random_state

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of the network and its nodes."""
        super()._prepare(context)
        rng = np.random.default_rng(self.random_state)
        probability = self.mean_degree / (self.n_nodes - 1)
        first = nx.gnp_random_graph(self.n_nodes, probability, seed=int(rng.integers(2**31)))
        second = LayerSpec('dependent', nx.gnp_random_graph(self.n_nodes, probability, seed=int(rng.integers(2**31))))
        functional = (rng.uniform(size=self.n_nodes) < self.p).astype(float)
        nodes = DependentNodeElement('nodes', active=functional, space=NetworkSpace(first, layers=[second]))
        cascade = InterdependenceInteraction('cascade', target='nodes', layer='dependent')
        self.system_ = System(self.label, elements=[nodes], interactions=[cascade])

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

  • DependentNodeElement, from Element

Interactions:

  • InterdependenceInteraction, from Interaction
class DependentNodeElement(Element):
    """Nodes of two interdependent networks, each functional or not by its value `active`.

    A node stands for a pair of nodes, one of each network, that depend on each other.

    Args:
        label:
            The label of the nodes.

        active:
            Whether a node is functional, 1 or 0, one per node or shared.

        space:
            The network of two layers with one node per site, or `None` for one node.

    Examples:
        >>> from skcomplex.systems.mathematics.networks import DependentNodeElement
        >>> DependentNodeElement('nodes', active=0.0).active
        0.0
    """

    visual = ACTIVITY_VISUAL

    def __init__(
        self,
        label: str,
        *,
        active: Annotated[object, FiniteEnumeratedSet([0, 1])] = 1.0,
        space: BaseSpace | None = None,
    ) -> None:
        super().__init__(label, space=space)
        self.active = active

class InterdependenceInteraction(Interaction):
    """Failure of every node that leaves the giant component of the functional nodes of either network.

    The steps alternate between the two networks: even steps keep the nodes of the giant component of the graph of the
    network, and odd steps those of the giant component of the layer `layer`, among the nodes functional so far.

    Args:
        label:
            The label of the interaction.

        target:
            The nodes whose values `active` the cascade sets.

        layer:
            The name of the layer of the second network.

    Examples:
        >>> from skcomplex.systems.mathematics.networks import InterdependenceInteraction
        >>> InterdependenceInteraction('cascade').layer
        'dependent'
    """

    law_classes = (UpdateLaw,)

    def __init__(self, label: str, *, target: Role = 'nodes', layer: str = 'dependent') -> None:
        super().__init__(label)
        self.target = target
        self.layer = layer

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the activity that survives the giant component of the network of the step as the law.

        Args:
            context:
                The namespace of the elements a binding of the roles names.
        """
        super()._prepare(context)
        node = context.target
        both = node.active * node.other.active
        first = components(both, reduce='giant')
        second = components(both, over=AdjacencyNeighborhood(layer=self.layer), reduce='giant')
        self.laws_: list[BaseLaw] = [
            UpdateLaw(node.active, node.active * where(mod(context.t, 2) < 1, first, second)),
        ]