cana.graphs.activity_graph module

Activity graphs of Boolean networks.

As proposed in Ghanbarnejad & Klemm (2012) EPL, 99. Edge weights are per-input activities (activities()). Optional interaction sign frozensets use the same conventions as interaction_graph.

The unthresholded graph includes every wiring edge (activity may be 0) and records G.graph["threshold"] is None. Pass that graph as base_ag to apply a threshold without recomputing activities. Applying a lower threshold (or None) than the base is an error — filtered edges cannot be recovered.

cana.graphs.activity_graph.build_activity_graph(nodes, name='', threshold=None, signed=False, base_ag=None)[source]

Build the activity graph from a sequence of Boolean nodes.

Pass base_ag (typically an unsigned, unthresholded AG) to reuse a cached graph without recomputing activities; base_ag is never mutated.

Parameters:
  • nodes (sequence) – Nodes with .name, .inputs, .activities(), and .input_signs() (when signed=True). Ignored for edge weights when base_ag is provided.

  • name (str) – Network name used in the digraph name attribute.

  • threshold (float, optional) – Keep edges with activity > threshold. When None, keep all wiring edges (including weight 0).

  • signed (bool) – Attach interaction sign frozensets. When True, works on a deep copy of the unsigned graph. Defaults to False.

  • base_ag (networkx.DiGraph, optional) – Cached activity graph. Must satisfy base_ag.graph["threshold"] is None or threshold >= base_ag.graph["threshold"]. Built from nodes when omitted.

Returns:

Activity graph with weight and sign.

G.graph["threshold"] records the applied threshold.

Return type:

G (networkx.DiGraph)