v0.3.3 — Graph-layer architecture review: model/renderer split, correctness + perf fixes, issue #1
LatestLarge architecture-review pass over the alphaDeesp graph layer: correctness
fixes, performance work, two deep revisions, the interactive-viewer
decomposition, and the fix for the multigraph Dijkstra-weight bug (#1).
Backward-compatible: all public import paths are unchanged
(from alphaDeesp.core.graphsAndPaths import ... still works). 418 unit tests
pass without grid2op; changes were cross-checked by adversarial multi-agent
verification. The grid2op integration suites and the new capacity-weighted
routing mode still want validation on reference grids in CI.
Bug fixes
- Multigraph Dijkstra weight in the null-flow path search (#1). On the overflow
MultiDiGraph, networkx passes a callable weight the{key: attr}parallel-edge view, so_compute_sssp_paths'attr.get("capacity", 0)read0— routing was hop-cost-only. The weight is now precomputed as an edge attribute (string-weight Dijkstra) with acapacity_weightedswitch:False(default) reproduces the historical behaviour bit-identical ("bless");Trueenables capacity-weighted routing with correct min-parallel capacity and(u,v)/(u,v,key)promoted matching ("fix"). Threaded throughadd_relevant_null_flow_lines[_all_paths]so downstream callers can opt in without patching. shortest_paths.py: removed a dead branch; made promoted-edge matching multigraph-correct (was silently weighting every parallel edge as0).OverFlowGraph.__init__no longer mutates the caller's DataFrame (copies it);rename_nodesclarified (behaviour unchanged).Structured_Overload_Distribution_Graph.get_dispatch_edges_nodesguards the empty-loops case (no moreTypeErroron a grid with no loop paths).to_DiGraphdefaults a missing edgecapacityto0.0(was1.0), which no longer skewsrank_red_loops' min-cut.
Deep revisions
OverFlowGraphmodel/renderer split: newOverflowGraphRendererowns all Graphviz presentation;OverFlowGraphkeeps the semantic model. Newedge_roles.py(edge_role_of,EDGE_ROLE_*,OverFlowGraph.edge_role) is the single authority mapping an edge's base colour to a role — no consumer parses colour strings;highlight_significant_line_loadingrecords an authoritativebase_color.AlphaDeespexplicit pipeline: ranking moved torun();AlphaDeesp(..., auto_run=True)(default) preserves previous behaviour,auto_run=Falsebuilds without side effects.- Lazy
Structured_Overload_Distribution_Graph: colour views,red_loopsandhubsarefunctools.cached_propertycomputed from a construction-time snapshot — behaviour-identical and order-independent.
Performance
delete_color_edgesaccepts a colour or an iterable of colours (single graph copy); derived views built in single passes.sort_hubsand the initial-inflow lookup vectorised (were per-hub / per-edgeiterrowsscans).simulation.create_dfvectorised (400-case differential fuzz pins equivalence).- Null-flow Dijkstra uses a precomputed string weight instead of a per-edge Python callable.
Maintainability & docs
core/interactive_html.py(976 LOC) split into thecore/interactive_html/package (8 focused modules) with CSS/JS/HTML externalised underassets/and reassembled byte-exactly at runtime (shipped viapackage_data).find_loops/ consolidation path enumeration gained opt-in cutoffs (defaultNone= unbounded = original behaviour).- New Architecture guide + autodoc API reference (
docs/ARCHITECTURE.rst,docs/API.rst);docs/CODE_REVIEW.md(full review + downstream-impact analysis onExpert_op4grid_recommender);CLAUDE.mdrefreshed.
Tests
New suites: test_edge_roles, test_overflow_renderer, test_simulation_create_df, test_null_flow_weighting, test_graph_consolidation, test_elements, test_simulation_helpers, test_alphadeesp_combinations; expanded test_graphs_package, test_overflow_graph, test_alphadeesp_unit, test_shortest_paths, test_interactive_html, test_topo_applicator.
Full changelog: v0.3.2.post4...v0.3.3