A compact Python library for modeling, analyzing, and visualizing optical network topologies.
Project description
Topolib 🚀
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!
- Show topology on a map 🗺️
- Show default topology in map 🗺️
- Export topology as PNG 🖼️
- Export topology to CSV and JSON 📄
- Export topology and k-shortest paths for FlexNetSim 🔀
- Generate traffic demand matrices 📊
- Generate multi-period traffic matrices with growth 📈
🧭 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, DC/IXP, distribution probability)
- Returns NumPy arrays for efficient mathematical operations
- Interactive map visualization with Folium and PyQt6
- Clean PNG export without external dependencies (no Selenium required)
- Resource caching for faster map rendering
- JSON import/export and interoperability
- 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.
📄 License
MIT — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
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 topolib-0.11.0.post2.dev0.tar.gz.
File metadata
- Download URL: topolib-0.11.0.post2.dev0.tar.gz
- Upload date:
- Size: 111.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d839d805e8cd79231c985bbcaf547f1ce0790ee5c4f1233ef589dff912e31060
|
|
| MD5 |
556159ce7dc82a5aa34564134600c5ae
|
|
| BLAKE2b-256 |
5373a8d15c02e1fc658938b7a8704c9c3a8265658272db487c490c8a44274365
|
File details
Details for the file topolib-0.11.0.post2.dev0-py3-none-any.whl.
File metadata
- Download URL: topolib-0.11.0.post2.dev0-py3-none-any.whl
- Upload date:
- Size: 163.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5455561757b5cf0f41cc0bdca824e99d36c044a5121f7f66ae5fc262ebcfdf36
|
|
| MD5 |
18e3c72b93611659bdb58158024df2a5
|
|
| BLAKE2b-256 |
07cdc1321ec96b33cfa813f3a3a41b98f1d3040574e2f5dc72c6cd0972d8813e
|