cana.canalization.cm_simplify module
Simplify Canalizing Map (CM) / Dynamics Canalization Map (DCM) graphs.
Provides threshold-unit classification, compatibility-gated reduction, and
simplify_canalizing_map() — a deterministic fixed-point rewrite that
reduces uppermost (farthest-from-out) units first.
- cana.canalization.cm_simplify.is_threshold_like(graph, node_id)[source]
True for
thresholdnodes and legacyfusion(τ≡1) units.- Parameters:
graph (DiGraph)
- Return type:
bool
- cana.canalization.cm_simplify.unit_tau(graph, node_id)[source]
Effective τ: fusion ≡ 1; threshold uses
tau; else None.- Parameters:
graph (DiGraph)
- Return type:
int | None
- cana.canalization.cm_simplify.classify_unit(graph, node_id)[source]
Return LINEAR / AND / OR / OTHER, or None if not classifiable as a unit.
Variables are always OR (fixed τ; never bumped). Fusion nodes are threshold-like with
tau=1(LINEAR ifn==1, else OR).- Parameters:
graph (DiGraph)
- Return type:
str | None
- cana.canalization.cm_simplify.reduction_skip_reason(graph, node_id)[source]
Return a skip reason, or None if reduction may be attempted.
- Parameters:
graph (DiGraph)
- Return type:
str | None
- cana.canalization.cm_simplify.reduction_compatible(graph, node_id)[source]
True if
reduce_threshold_unit()may be applied to node_id.- Parameters:
graph (DiGraph)
- Return type:
bool
- cana.canalization.cm_simplify.reduce_threshold_unit(graph, node_id, *, copy=True)[source]
Apply the uniform threshold-unit reduction to node_id.
Wire all predecessors to all successors, bump each threshold/fusion successor by
tau(T)-1, deleteT. Assumesreduction_compatible()already passed.- Parameters:
graph (DiGraph)
copy (bool)
- Return type:
DiGraph
- cana.canalization.cm_simplify.simplify_canalizing_map(cm, *, copy=True, remove_isolates=True, skip_if_edges_increase=False)[source]
Simplify a CM / DCM by threshold-unit reduction (fixed point).
Safe rewrite rules applied until no candidate remains:
Never remove or rewrite
tau=0thresholds (constant schemata).Threshold-unit reduction: if a threshold/fusion unit is LINEAR / AND / OR / OTHER and every successor class is compatible, wire all predecessors to all successors, bump each threshold/fusion successor by
tau(T)-1, and deleteT. Variables are never bumped. Compatibility:LINEAR → AND, OR, LINEAR, OTHER
AND → AND, LINEAR
OR → OR, LINEAR
OTHER → LINEAR
Non-schema OR/LINEAR units that claim variables are eligible.
Candidates are ordered farthest-from-out first (largest directed distance to a
variablenode), then bystr(node_id). One rewrite is applied per iteration.- Parameters:
cm (networkx.DiGraph) – Canalizing map or dynamics canalization map.
copy (bool, optional) – If
True(default), operate on a copy and leave cm unchanged.remove_isolates (bool, optional) – If
True(default), drop isolated nodes after rewriting.skip_if_edges_increase (bool, optional) – If
True, skip a reduction when wiring preds→succs would add more edges than removing the unit deletes. Reductions that leave the edge count unchanged are still applied. DefaultFalse.
- Returns:
Simplified graph (a copy unless
copy=False).- Return type:
networkx.DiGraph