cana.graphs.interaction_graph module

Interaction (wiring) graphs of Boolean networks.

Nodes are variables; an edge source -> target exists when source is an input of target. Edge weight is 1.0 (topology only). Edge sign is an Optional[frozenset[int]]:

  • None when signed=False (not computed)

  • frozenset({1}) / frozenset({-1}) — pure activation / inhibition

  • frozenset({1, -1}) — binate / dual-sign

  • frozenset() — irrelevant (no influence)

cana.graphs.interaction_graph.fill_wiring_signs(G, nodes)[source]

Set edge sign frozensets from each target node’s input_signs.

Parameters:
  • G (networkx.DiGraph) – Digraph whose nodes are integer node ids.

  • nodes (sequence) – Nodes with .inputs and .input_signs(), indexed by id (typically BooleanNetwork.nodes).

Returns:

The same graph, mutated in place.

Return type:

G (networkx.DiGraph)

cana.graphs.interaction_graph.build_interaction_graph(nodes, name='', remove_constants=False, signed=True, constant_ids=None)[source]

Build the interaction graph from a sequence of Boolean nodes.

Parameters:
  • nodes (sequence) – Nodes with .name, .inputs, and .input_signs() (when signed=True).

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

  • remove_constants (bool) – Drop constant nodes. Defaults to False.

  • signed (bool) – Compute and attach interaction signs. Defaults to True.

  • constant_ids (iterable, optional) – Node ids removed when remove_constants is True. Ignored otherwise.

Returns:

The interaction graph.

Return type:

G (networkx.DiGraph)