Py3plex Documentation
py3plex enables scalable analysis and visualization of multilayer and multiplex networks in Python, supporting complex network modeling across diverse scientific and applied domains.
Overview
py3plex is a lightweight Python library designed specifically for analyzing and visualizing heterogeneous and multilayer networks. Unlike traditional network analysis tools that focus on homogeneous networks (single node and edge type), py3plex provides specialized capabilities for networks with:
Multiple node types
Multiple edge types
Multiple layers of interaction
Temporal dynamics
Heterogeneous attributes
Target Users: Researchers in network science, computational biology, complex systems, social network analysis, and applied network modeling.
Key Features:
Native support for multiplex and multilayer network structures
Diagonal projection visualization for large multilayer networks
Comprehensive multilayer centrality measures
Community detection across network layers
Network decomposition and feature extraction
Semantic enrichment with external knowledge bases
Integration with NetworkX, igraph, and other graph libraries
Installation
Install from GitHub
pip install git+https://github.com/SkBlaz/py3plex.git
Install from source for development
git clone https://github.com/SkBlaz/py3plex.git
cd py3plex
pip install -e .
Optional Dependencies
# Advanced community detection with Infomap
pip install git+https://github.com/SkBlaz/py3plex.git#egg=py3plex[infomap]
# Additional algorithms (Louvain, cdlib)
pip install git+https://github.com/SkBlaz/py3plex.git#egg=py3plex[algos]
# Advanced visualization (plotly, igraph)
pip install git+https://github.com/SkBlaz/py3plex.git#egg=py3plex[viz]
# For development (includes testing and linting tools)
pip install -e ".[dev]"
Requirements
Python 3.8 or higher
NetworkX, NumPy, SciPy (automatically installed)
Optional: Matplotlib, Plotly for visualization
Quick Start
Create a simple multilayer network:
from py3plex.core import multinet
# Create a new multilayer network
network = multinet.multi_layer_network()
# Add edges within layers
network.add_edges([
['A', 'layer1', 'B', 'layer1', 1],
['B', 'layer1', 'C', 'layer1', 1],
['A', 'layer2', 'B', 'layer2', 1],
], input_type="list")
# Display basic statistics
network.basic_stats()
# Visualize
from py3plex.visualization.multilayer import draw_multilayer_default
draw_multilayer_default([network], display=True)
Load from file and analyze:
# Load from edge list
network = multinet.multi_layer_network().load_network(
"data.edgelist", input_type="edgelist", directed=False)
# Compute multilayer statistics
from py3plex.algorithms.statistics import multilayer_statistics as mls
density = mls.layer_density(network, 'layer1')
versatility = mls.versatility_centrality(network, centrality_type='degree')
# Community detection
from py3plex.algorithms.community_detection import community_wrapper
communities = community_wrapper.best_partition(network.core_network)
Why py3plex?
vs. NetworkX: NetworkX excels at single-layer homogeneous networks but lacks native multilayer support. py3plex builds on NetworkX while adding:
Native multilayer data structures
Layer-aware algorithms
Specialized multilayer visualizations
Heterogeneous network decomposition
vs. Other Multilayer Tools: py3plex provides:
Lightweight and easy to integrate
Comprehensive statistical measures (17+ multilayer metrics)
Publication-ready visualizations
Active development and research backing
Use Cases
py3plex is particularly well-suited for:
Biological networks: Protein-protein interactions with multiple evidence types, gene regulatory networks
Social networks: Multi-platform analysis (Twitter + Facebook), relationship type analysis
Citation networks: Author-paper-venue multilayer structures, knowledge graphs
Transportation: Multi-modal networks (bus, train, air), urban mobility
Temporal networks: Evolving social networks, dynamic community evolution
Documentation Contents
Getting Started
- Installation and Setup
- Quickstart Guide
- 10-Minute Tutorial: Getting Started with Py3plex
- What You’ll Learn
- Prerequisites
- 1. Creating Your First Multilayer Network (2 minutes)
- 2. Loading Networks from Files (1 minute)
- 3. Exploring Network Structure (2 minutes)
- 4. Computing Network Metrics (2 minutes)
- 5. Multilayer Network Statistics (2 minutes)
- 6. Community Detection (2 minutes)
- 7. Random Walks (1 minute)
- 8. Basic Visualization (1 minute)
- Complete Example: Putting It All Together
- Next Steps
- Common Issues
- Tips for Success
- Core Principles
User Guide
Tutorials
Advanced Topics
API Reference
Contributing
Examples
The best way to learn py3plex is through examples!
All examples are available in the examples/ directory.
Key examples:
tutorial_10min.py
- Executable version of the 10-minute tutorialexample_random_walks.py
- Random walk primitives (Node2Vec, DeepWalk)example_multilayer_visualization.py
- Network visualizationexample_community_detection.py
- Community detection with Louvain and Infomapexample_network_decomposition.py
- Meta-path feature extractionexample_multilayer_statistics.py
- Computing multilayer metricsexample_n2v_embedding.py
- Node2Vec embeddingsexample_label_propagation.py
- Semi-supervised learning
Citation
If you use py3plex in your research, please cite:
@Article{Skrlj2019,
author={Škrlj, Blaž and Kralj, Jan and Lavrač, Nada},
title={Py3plex toolkit for visualization and analysis of multilayer networks},
journal={Applied Network Science},
year={2019},
volume={4},
number={1},
pages={94},
doi={10.1007/s41109-019-0203-7}
}