Metadata-Version: 2.4
Name: topolib
Version: 0.17.1
Summary: A compact Python library for modeling, analyzing, and visualizing optical network topologies.
License: MIT
License-File: LICENSE
Keywords: network,topology,optical,analysis,visualization
Author: Danilo Bórquez-Paredes
Author-email: danilo.borquez.p@uai.cl
Requires-Python: >=3.10
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Telecommunications Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: PyQt6 (>=6.0)
Requires-Dist: PyQt6-WebEngine (>=6.0)
Requires-Dist: folium (>=0.14.0)
Requires-Dist: jsonschema (>=4.0)
Requires-Dist: networkx (>=2.6)
Requires-Dist: numpy (>=1.21)
Requires-Dist: scipy (>=1.7)
Project-URL: Documentation, https://topolib.readthedocs.io/
Project-URL: Homepage, https://gitlab.com/DaniloBorquez/topolib
Project-URL: Repository, https://gitlab.com/DaniloBorquez/topolib
Description-Content-Type: text/markdown

# Topolib 🚀

[![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](LICENSE)
[![Issues](https://img.shields.io/badge/issues-on%20GitLab-blue.svg)](https://gitlab.com/DaniloBorquez/topolib/-/issues)
[![Develop coverage](https://gitlab.com/DaniloBorquez/topolib/badges/develop/coverage.svg)](https://gitlab.com/DaniloBorquez/topolib/-/pipelines?ref=develop)
[![Documentation Status](https://readthedocs.org/projects/topolib/badge/?version=latest)](https://topolib.readthedocs.io/en/latest/?badge=latest)

> **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/`](https://gitlab.com/DaniloBorquez/topolib/-/tree/main/examples) folder!

- **[Jupyter Notebook - Complete Example](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/jupyter_notebook_example.ipynb) 📓** ⭐ NEW! Interactive example showing all features
- [Show topology on a map](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/show_topology_in_map.py) 🗺️
- [Show default topology in map](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/show_default_topology_in_map.py) 🗺️
- [Export topology as PNG](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/export_topology_png.py) 🖼️
- [Export topology in paper format](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/export_paper_format.py) 📄
- [Work with adjacency matrices](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/adjacency_matrices.py) 📊
- [Export topology to CSV and JSON](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/export_csv_json.py) 📄
- [Export topology and k-shortest paths for FlexNetSim](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/export_flexnetsim.py) 🔀
- [Generate traffic demand matrices](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/traffic_matrices.py) 📊
- [Generate multi-period traffic matrices with growth](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/examples/multiperiod_traffic_matrices.py) 📈

---

## 🧭 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
- **Fully compatible with Jupyter Notebook** - Folium maps display inline for interactive analysis
- Ready for Sphinx, Read the Docs, and PyPI

---

## ⚡ Quickstart

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

---

## 📚 Documentation

Full documentation: [https://topolib.readthedocs.io/](https://topolib.readthedocs.io/)

---

## 📝 Basic usage

### Creating a topology

```python
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

```python
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`](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/CONTRIBUTING.md) for development guidelines, commit message rules, and pre-commit setup.

---

## 📄 License

MIT — see [`LICENSE`](https://gitlab.com/DaniloBorquez/topolib/-/blob/main/LICENSE) for details.

