Skip to main content

Package to solve Steiner Tree and Steiner Forest Problems with the HiGHS solver

Project description

SteinerPy

PyPI version Python 3.8+ License: MIT CI/CD codecov

A Python package for solving Steiner Tree and Steiner Forest Problems using the HiGHS solver and NetworkX graphs.

Installation

Install SteinerPy using pip:

pip install steinerpy

Or using uv:

uv add steinerpy

Quick Start

import networkx as nx
from steinerpy import SteinerProblem

# Create a graph
G = nx.Graph()
G.add_edge('A', 'B', weight=1)
G.add_edge('B', 'C', weight=2)
G.add_edge('C', 'D', weight=1)

# Define terminal groups
terminal_groups = [['A', 'D']]

# Solve the Steiner problem
problem = SteinerProblem(G, terminal_groups)
solution = problem.get_solution()

print(f"Optimal cost: {solution.objective}")
print(f"Selected edges: {solution.selected_edges}")

Usage Examples

See the example.ipynb notebook for detailed usage examples.

Dependencies

  • networkx: For graph representation and manipulation
  • highspy: For optimization solving

If you use this package 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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

steinerpy-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

steinerpy-0.1.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file steinerpy-0.1.2.tar.gz.

File metadata

  • Download URL: steinerpy-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for steinerpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1b8eb5bd03e663f9cf130faab8b6e8891a655a09404cdd1f4ca3edebc3c85597
MD5 1876ec10d227882b454d5ef3ef35fa8e
BLAKE2b-256 bce719c4752a0b7d918235c05c6f8aecdc0c0cdb7d994f1f9855005d405fc5ef

See more details on using hashes here.

File details

Details for the file steinerpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: steinerpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for steinerpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38185def9c8c0faf4d36da9455faa6474f0b14dcd811cdbb723bfc916055a526
MD5 4e697dda637e3fd09e6ef0a618e7039c
BLAKE2b-256 edfc269b06f2502fdbce2483b41cbcb3e2c3e977b9a555dcb98bd3b073fca238

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page