Skip to main content

A compact Python library for modeling, analyzing, and visualizing optical network topologies.

Project description

Topolib 🚀

Python Version License Issues Develop coverage Documentation Status

Topolib is a compact, modular Python library for modeling, analyzing, and visualizing optical network topologies.
Goal: Provide researchers and engineers with a simple, extensible toolkit for working with nodes, links, metrics, and map-based visualizations.

🌐 Model | 📊 Analyze | 🗺️ Visualize | 🧩 Extend


📂 Examples

Explore ready-to-run usage examples in the examples/ folder!


🧭 Overview

Topolib is organized into four main modules:

  • 🧱 Elements: Node, Link — basic building blocks
  • 🕸️ Topology: Topology, Path — manage nodes, links, paths, and adjacency
  • 📈 Analysis: Metrics, TrafficMatrix — compute node degree, link stats, connection matrices, and traffic demand matrices
  • 🖼️ Visualization: MapView — interactive maps with Folium and PyQt6, clean PNG exports

✨ Features

  • Modular, extensible design
  • Easy-to-use classes for nodes, links, and paths
  • Built-in metrics and analysis helpers
  • Traffic demand matrix generation with three models (gravitational, MPT, RAM)
  • Returns NumPy arrays for efficient mathematical operations
  • Interactive map visualization with Folium and PyQt6
  • Clean PNG export without external dependencies (no Selenium required)
  • Paper format export with white background for academic publications
  • Resource caching for faster map rendering
  • JSON import/export and interoperability
  • 60+ built-in topologies available as downloadable CSV files from the Topology Repository (no Python environment required)
  • Fully compatible with Jupyter Notebook - Folium maps display inline for interactive analysis
  • Ready for Sphinx, Read the Docs, and PyPI

⚡ Quickstart

python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install topolib

📚 Documentation

Full documentation: https://topolib.readthedocs.io/


📝 Basic usage

Creating a topology

from topolib.elements.node import Node
from topolib.topology.topology import Topology

n1 = Node(1, 'A', 10.0, 20.0)
n2 = Node(2, 'B', 11.0, 21.0)
topo = Topology(nodes=[n1, n2])
# Add links, compute metrics, visualize, etc.

Generating traffic matrices

from topolib.topology import Topology
from topolib.analysis import TrafficMatrix

# Load a topology
topo = Topology.load_default_topology("Germany-14nodes")

# Generate traffic matrix using gravitational model
matrix = TrafficMatrix.gravitational(topo, rate=0.015)
# Returns NumPy array: matrix[i, j] = traffic from node i to j (Gbps)

# Export to CSV
TrafficMatrix.to_csv(matrix, topo, "traffic_matrix.csv")

# Export to JSON (list of demands with src, dst, required fields)
TrafficMatrix.to_json(matrix, topo, "traffic_matrix.json")

🛠️ Development

See CONTRIBUTING.md for development guidelines, commit message rules, and pre-commit setup.


� Acknowledgments

Topolib builds upon excellent open-source projects:

Core Dependencies:

  • NumPy (BSD-3-Clause) — numerical computing
  • NetworkX (BSD-3-Clause) — graph analysis
  • SciPy (BSD-3-Clause) — scientific computing
  • Folium (MIT) — interactive maps
  • jsonschema (MIT) — JSON validation

Visualization:

All dependencies are compatible with Topolib's MIT license. PyQt6 is used only for optional interactive visualization features and is not required for core topology modeling and analysis functionality.


�📄 License

MIT — see LICENSE for details.

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

topolib-0.20.1.tar.gz (117.3 kB view details)

Uploaded Source

Built Distribution

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

topolib-0.20.1-py3-none-any.whl (168.7 kB view details)

Uploaded Python 3

File details

Details for the file topolib-0.20.1.tar.gz.

File metadata

  • Download URL: topolib-0.20.1.tar.gz
  • Upload date:
  • Size: 117.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/5.15.154+

File hashes

Hashes for topolib-0.20.1.tar.gz
Algorithm Hash digest
SHA256 1cfa220e204f8d84cbcb2f55733af67b12b839a9c6cff5a095c0c524ab1e4e63
MD5 6b96e96478a9e585bf36b8dd45d30b30
BLAKE2b-256 bc3710ebe563b040da32160dbfb3d82819cb8bd1bbf107666b88dd58193c8d0d

See more details on using hashes here.

File details

Details for the file topolib-0.20.1-py3-none-any.whl.

File metadata

  • Download URL: topolib-0.20.1-py3-none-any.whl
  • Upload date:
  • Size: 168.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/5.15.154+

File hashes

Hashes for topolib-0.20.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7dcd28e528f40b16c15d499e59ba1bd4469db914f86950a17b980bb0115d48b
MD5 ab3c7ab480ed2ce31864c78e198b5d73
BLAKE2b-256 27ec1e4c8efcb8f1799d4f72b0fe3c6ff0ca46d9d429c247a775a1cda04bef79

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