DenseGraph

experimental.network_dynamics.graph.DenseGraph(
    weights,
    region_labels=None,
    symmetric=None,
)

Dense graph representation.

Standard dense matrix representation of network topology. Suitable for most brain networks which are typically 50-90% dense.

Args: weights: Weight matrix [n_nodes, n_nodes] region_labels: Optional sequence of region labels (list, tuple, or array). If None, defaults to [‘Region_0’, ‘Region_1’, …] symmetric: Whether to treat as symmetric (None = auto-detect)

Attributes

Name Description
n_nodes Number of nodes in the network.
region_labels Labels for each node/region in the network.
sparsity Calculate the sparsity of the graph (fraction of non-zero connections).
symmetric Check if the graph is symmetric (undirected).
weights Weight matrix [n_nodes, n_nodes].

Methods

Name Description
plot Plot connectivity matrix and weight distribution.
random Create a random graph with brain-like connectivity.
tree_flatten Flatten Graph for JAX PyTree.
tree_unflatten Reconstruct Graph from PyTree data.
verify Verify graph structure and properties.

plot

experimental.network_dynamics.graph.DenseGraph.plot(
    log_scale_weights=False,
    figsize=(12, 5),
)

Plot connectivity matrix and weight distribution.

Args: log_scale_weights: If True, log-transform weights before plotting (helps reveal structure) figsize: Figure size (width, height)

Returns: fig, axes: Matplotlib figure and axes

random

experimental.network_dynamics.graph.DenseGraph.random(
    n_nodes,
    sparsity=0.7,
    symmetric=True,
    weight_dist='lognormal',
    allow_self_loops=False,
    key=None,
)

Create a random graph with brain-like connectivity.

Args: n_nodes: Number of nodes in the network sparsity: Fraction of connections present (0.7 = 70% dense) symmetric: Whether to create undirected (symmetric) connectivity weight_dist: Weight distribution (‘lognormal’, ‘uniform’, or ‘binary’) allow_self_loops: Whether to allow self-connections (diagonal) key: JAX random key (if None, creates one with seed 0)

Returns: DenseGraph with random connectivity

Example: >>> import jax >>> key = jax.random.key(42) >>> graph = DenseGraph.random(n_nodes=10, sparsity=0.5, key=key)

tree_flatten

experimental.network_dynamics.graph.DenseGraph.tree_flatten()

Flatten Graph for JAX PyTree.

tree_unflatten

experimental.network_dynamics.graph.DenseGraph.tree_unflatten(
    aux_data,
    children,
)

Reconstruct Graph from PyTree data.

verify

experimental.network_dynamics.graph.DenseGraph.verify(verbose=True)

Verify graph structure and properties.

Checks: - Finite values in weight matrix - Consistent shape - Symmetric flag consistency (if provided)

Args: verbose: Whether to print verification details

Returns: True if verification passes, False otherwise