Py3plex: Multilayer Network Analysis

Py3plex Visualization Showcase Tests Code Quality

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

Key features at a glance:

  • 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. Both return the same results; pick the style that fits your workflow.

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

Get started in three steps: install, build a tiny multilayer network, and inspect it.

Step 1 — Install

pip install py3plex

Step 2 — 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

Counts reflect per-layer node identities (Alice/Bob/Carol each appear in two layers). Your totals will differ if you change the edge list. The visualization opens in a Matplotlib window and colors nodes by layer.

Start Here

New to py3plex? Start with 10-Minute Tutorial to move from basics to a full analysis in about 10 minutes.

Already familiar with multilayer networks? Jump to How to Run Community Detection on Multilayer Networks or browse How-to Guides for task-focused guides.

Just need the API? See 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. Use the outline below to jump directly to the content type you need—tutorials for learning, how-to guides for tasks, explanations for concepts, and reference for precise details.

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