Py3plex: Multilayer Network Analysis

Py3plex Visualization Showcase Tests Code Quality

Documentation Versions

You are viewing the documentation for py3plex 1.x (current stable version). These docs are actively maintained and updated.

Legacy documentation for py3plex 0.8x is still available at https://py3plex.readthedocs.io but is no longer updated. Most users should use the 1.x docs you’re reading now.

Which version should you use? See Which Docs Should I Use? below for guidance.


py3plex provides scalable analysis and visualization of multilayer and multiplex networks in Python.

Key Features:

  • Multiplex and multilayer network structures

  • SQL-like DSL for network queries — first-class feature

  • 17+ multilayer statistics and centrality measures

  • Community detection (Louvain, Infomap, multilayer modularity)

  • Random walk algorithms (Node2Vec, DeepWalk) for embeddings

  • Publication-ready visualizations

  • High-performance I/O with Arrow/Parquet support

  • Full NetworkX compatibility

DSL: Query Networks Like SQL

The py3plex DSL lets you query networks using intuitive SQL-like syntax or a type-safe Python builder API:

from py3plex.dsl import execute_query, Q, L

# String DSL: Simple and readable
result = execute_query(network,
    'SELECT nodes WHERE layer="social" AND degree > 5 '
    'COMPUTE betweenness_centrality'
)

# Builder API: Type-safe with autocompletion
result = (
    Q.nodes()
     .from_layers(L["social"])
     .where(degree__gt=5)
     .compute("betweenness_centrality")
     .order_by("-betweenness_centrality")
     .limit(10)
     .execute(network)
)

The DSL is perfect for:

  • Interactive network exploration

  • Rapid prototyping

  • Educational purposes

  • Production pipelines

See the complete SQL-like DSL for Multilayer Networks guide for all features!

Quickstart

Install:

pip install py3plex

Create a multilayer network:

from py3plex.core import multinet

network = multinet.multi_layer_network()
network.add_edges([
    ['Alice', 'friends', 'Bob', 'friends', 1],
    ['Bob', 'friends', 'Carol', 'friends', 1],
    ['Alice', 'colleagues', 'Bob', 'colleagues', 1],
], input_type="list")

network.basic_stats()
network.visualize_network(show=True)

Expected output:

Number of nodes: 6
Number of edges: 3

Start Here

New to py3plex? → Begin with the 10-Minute Tutorial to go from basics to advanced analysis in 10 minutes.

Already familiar with multilayer networks? → Jump to How to Run Community Detection on Multilayer Networks or explore the How-to Guides.

Just need the API? → Go straight to API Documentation or DSL Reference.

Want to understand the concepts? → Read Multilayer Networks 101 for the theory behind multilayer networks.

Documentation Structure

This documentation follows the Diátaxis framework with 7 top-level sections:

Part I: Overview

High-level introduction to py3plex and multilayer networks.


Part II: Getting Started (Tutorials)

Step-by-step tutorials for beginners. Start here if you’re new to py3plex.


Part III: How-to Guides

Task-oriented guides answering “How do I…?” questions.

How-to Guides


Part IV: Concepts & Explanations

Theoretical background and architectural explanations.


Part V: API & DSL Reference

Complete reference documentation for APIs and DSL syntax.

API & DSL Reference


Part VI: Examples & Recipes

Complete working examples and analysis recipes.


Part VII: Project Info

Project information, contributing guidelines, and citations.


Additional Sections

Citation

If you use py3plex in your research, please cite:

@Article{Skrlj2019,
  author={Skrlj, Blaz and Kralj, Jan and Lavrac, 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}
}

Indices and Tables