You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix#122: Add SteinerTree model (rebased on main)
Clean rebase onto current main. Adds SteinerTree<G, W> with edge-based
binary variables, BFS+tree validity checker, Dreyfus-Wagner complexity,
full CLI integration (create, example, random), paper entry with CeTZ
figure, and 18 unit tests including coverage for all public methods.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Final review fixes: display-name order, random terminals, paper example from fixtures
- Move SteinerTree display-name entry to correct alphabetical position
- Use seeded Fisher-Yates shuffle for random terminal selection instead
of always picking first N vertices
- Rewrite paper example to use load-model-example() from canonical
examples.json fixtures instead of hand-written values
- Regenerate example fixtures to include SteinerTree model
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Derive terminal-terminal edge from fixture data in paper example
Replace hardcoded (v2,v4) reference with data-driven lookup from
the canonical example, eliminating the last hardcoded instance value.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: random terminal selection and regenerate example fixtures
- Add lcg_choose() utility for Fisher-Yates partial shuffle
- Use random terminal selection and random edge weights in SteinerTree random generation
- Regenerate examples.json to include SteinerTree canonical example
- Fix pre-existing formatting issues from main merge
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: GiggleLiu <cacate0129@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Given an undirected graph $G = (V, E)$ with edge weights $w: E -> RR_(>= 0)$ and a set of terminal vertices $T subset.eq V$ with $|T| >= 2$, find a tree $S = (V_S, E_S)$ in $G$ such that $T subset.eq V_S$, minimizing $sum_(e in E_S) w(e)$. Vertices in $V_S backslash T$ are called _Steiner vertices_.
811
+
][
812
+
One of Karp's 21 NP-complete problems @karp1972, foundational in network design with applications in telecommunications backbone routing, VLSI chip interconnect, pipeline planning, and phylogenetic tree construction. When $T = V$, the problem reduces to the minimum spanning tree (polynomial). The NP-hardness arises from choosing which Steiner vertices to include.
813
+
814
+
The best known exact algorithm runs in $O^*(3^(|T|)dot n + 2^(|T|)dot n^2)$ time via Dreyfus--Wagner dynamic programming over terminal subsets @dreyfuswagner1971. Byrka _et al._ achieved a $ln(4) + epsilonapprox 1.39$-approximation @byrka2013; the classic 2-approximation uses the minimum spanning tree of the terminal distance graph.
815
+
816
+
// Find the unique direct terminal-terminal edge (both endpoints in T, not in the optimal tree)
*Example.* Consider $G$ with $n = #nv$ vertices, $m = #ne$ edges, and terminals $T = {#terminals.map(t=>$v_#t$).join(", ")}$. The optimal Steiner tree uses edges ${#tree-edges.map(e=>$(v_#(e.at(0)), v_#(e.at(1)))$).join(", ")}$ with Steiner vertices ${#steiner-verts.map(v=>$v_#v$).join(", ")}$ acting as relay points. The total cost is #tree-edge-indices.map(i=>$#(weights.at(i))$).join($+$) $= #cost$. Note the only direct terminal--terminal edge $(v_#tt-u, v_#tt-v)$ has weight #weights.at(tt-idx), equaling the entire Steiner tree cost.
label: text(fill: ifis-terminal { white } else { black })[$v_#k$])
848
+
}
849
+
})
850
+
},
851
+
caption: [Steiner tree on #nv vertices with terminals $T = {#terminals.map(t=>$v_#t$).join(", ")}$ (filled blue). Steiner vertices #steiner-verts.map(v=>$v_#v$).join(", ") (outlined) relay connections. Blue edges form the optimal tree with cost #cost.],
852
+
) <fig:steiner-tree>
853
+
]
854
+
]
855
+
}
789
856
#problem-def("OptimalLinearArrangement")[
790
857
Given an undirected graph $G=(V,E)$ and a non-negative integer $K$, is there a bijection $f: V -> {0, 1, dots, |V|-1}$ such that $sum_({u,v} in E) |f(u) - f(v)| <= K$?
0 commit comments