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

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.1.tar.gz (8.7 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.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: steinerpy-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 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.1.tar.gz
Algorithm Hash digest
SHA256 99fd153a63df550900e451db095a2404ecd4abb27931b28bba78bca43bd54488
MD5 1a2d9d4213fbd01b3cf38b19ed0a80e5
BLAKE2b-256 827f477a180f36c701eb22922f8f841140241968a779c4fe658fa21285dd275e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: steinerpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8aa75050d2398af2584c6188fa63aec1c4709c5154ea670be03713c932e805c3
MD5 f73bfb2c8300898a5524f78bea5dfbff
BLAKE2b-256 bff25ff41e0e8bac5c958b6829746426779d62972ce0a3282341fc5e537de432

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