SteinerPy
SteinerPy solves Steiner tree and Steiner forest problems — and many advanced variants — to proven optimality, directly on NetworkX graphs. It uses the open-source HiGHS solver by default, with Gurobi supported as an optional backend.
- One API, many variants — Steiner tree/forest, prize-collecting, node-weighted, maximum-weight connected subgraph, directed (arborescence), hop-constrained, group, rectilinear, terminal-leaf, and budgeted variants.
- Exact, with a certificate — every solve reports a proven optimality gap;
gap == 0.0means provably optimal. - Fast by default — provably optimum-preserving graph reductions from the Steiner-tree literature run automatically, plus an opt-in dual-ascent accelerator and a heuristic-only mode that stays in NetworkX's speed class while still certifying its gap.
📖 Documentation: steinerpy.readthedocs.io
Installation
pip install steinerpy
Requires Python 3.8+. The HiGHS backend is installed automatically; to use Gurobi instead, install gurobipy and provide a valid license.
Quick start
import networkx as nx
from steinerpy import SteinerProblem
G = nx.Graph()
G.add_edge("A", "B", weight=1)
G.add_edge("B", "C", weight=2)
G.add_edge("C", "D", weight=1)
# One terminal group = Steiner tree; multiple groups = Steiner forest
solution = SteinerProblem(G, [["A", "D"]]).get_solution()
print(f"Optimal cost: {solution.objective}")
print(f"Selected edges: {solution.selected_edges}")
print(f"Proven optimality gap: {solution.gap}") # 0.0 == provably optimal
See the documentation for the full catalogue of problem variants, solver selection, performance features (dual ascent, graph reductions, heuristic-only mode), benchmarks against NetworkX and pcst_fast, and the API reference. The example notebook walks through the main features.
Citing
If you use SteinerPy in your research, please cite:
@article{markhorst2025future,
title={Future-proof ship pipe routing: Navigating the energy transition},
author={Markhorst, Berend and Berkhout, Joost and Zocca, Alessandro and Pruyn, Jeroen and van der Mei, Rob},
journal={Ocean Engineering},
volume={319},
pages={120113},
year={2025},
publisher={Elsevier}
}
Contributing
Contributions are very welcome! Please read the contributing guidelines and open an issue to discuss your idea before starting on a pull request.
License
SteinerPy is available under the MIT license.
Star History
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file steinerpy-1.0.16.tar.gz.
File metadata
- Download URL: steinerpy-1.0.16.tar.gz
- Upload date:
- Size: 106.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb602a9ef8808e24523c8b99961ff8c28c9382826bdd933e62ac60b76b3a30fc
|
|
| MD5 |
44e70b1628cf8d865d9898c97423eb9f
|
|
| BLAKE2b-256 |
092d59636deefeee1fb13e99075906792aefdab7788b687fdc5551e17589df95
|
File details
Details for the file steinerpy-1.0.16-py3-none-any.whl.
File metadata
- Download URL: steinerpy-1.0.16-py3-none-any.whl
- Upload date:
- Size: 107.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40a6f8e0f1d0dc2d5e399e0e26a3188f16a97cc08c84ccd2411d7b6a38c3ee3d
|
|
| MD5 |
26ac697696c2c4ec9f1fb8bf486738d0
|
|
| BLAKE2b-256 |
fcac00807bc5e84cc664871d9a3fe9f64474881a9309cb09ace7a5689cfdf708
|