Skip to content

Networks

Network realizations shared by the biology packages: weighted edges of ecological networks and their draws.

EdgeDrawInteraction(label, *, target, edges, noise=0.0, low=-1.0, high=1.0, state='w')

Bases: NeighborInteraction

First draw of the weight of every new edge of a network, and a random drift of the weights of the other edges.

Every step of discrete time an edge marked fresh draws its weight uniformly from [low, high] and loses its mark, and every other edge adds noise times a standard normal draw to its weight, or keeps it without noise.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Annotated[str, RoleSpec()]

The path of the group on the nodes of the network.

required
edges Annotated[str, RoleSpec()]

The path of the group on its edges, whose members hold the weight and the mark.

required
noise Annotated[float, ParameterSpec(domain=closed_open(0, oo))]

The standard deviation of the drift of a weight in a step, 0 for none.

0.0
low float

The least weight of a new edge.

-1.0
high float

The largest weight of a new edge.

1.0
state str

The name of the state of the edges that holds the weight.

'w'

Examples:

>>> from types import SimpleNamespace
>>> from sage.all__sagemath_symbolics import var
>>> from skcomplex.models.biology.common.networks import EdgeDrawInteraction
>>> edge = SimpleNamespace(w=var('w'), fresh=var('fresh'))
>>> draw = EdgeDrawInteraction('draw', target='species', edges='links').check().prepare()
>>> [str(law.value) for law in draw.run(SimpleNamespace(edge=edge, noise=var('noise'))).laws_][1]
'0'
Source code in src/skcomplex/models/biology/common/networks/_edge_draw.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def __init__(
    self,
    label: str,
    *,
    target: Annotated[str, RoleSpec()],
    edges: Annotated[str, RoleSpec()],
    noise: Annotated[float, ParameterSpec(domain=RealSet.closed_open(0, oo))] = 0.0,
    low: float = -1.0,
    high: float = 1.0,
    state: str = 'w',
) -> None:
    super().__init__(label)
    self.target = target
    self.edges = edges
    self.noise = noise
    self.low = low
    self.high = high
    self.state = state

WeightedEdgeElement(label, visual=None, *, w=0.0, fresh=1.0)

Bases: Element

Edge of a network with a weight w, such as the strength of an influence or a coupling between two species.

A new edge is marked fresh until an EdgeDrawInteraction draws its weight.

Parameters:

Name Type Description Default
label str

The label of the edge or of the group of edges.

required
visual VisualSpec | None

How the element is drawn, or None for default_visual_.

None
w Annotated[float, StateSpec()]

The weight.

0.0
fresh Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]

Whether the edge has not drawn its weight yet, 1 or 0.

1.0

Examples:

>>> from skcomplex.models.biology.common.networks import WeightedEdgeElement
>>> WeightedEdgeElement('edge').fresh
1.0
Source code in src/skcomplex/models/biology/common/networks/_weighted_edge.py
38
39
40
41
42
43
44
45
46
47
48
def __init__(
    self,
    label: str,
    visual: VisualSpec | None = None,
    *,
    w: Annotated[float, StateSpec()] = 0.0,
    fresh: Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))] = 1.0,
) -> None:
    super().__init__(label, visual=visual)
    self.w = w
    self.fresh = fresh