Skip to main content

NDlib - Network Diffusion Library

pyversions Build Status Coverage Status Documentation Status DOI Downloads Downloads SBD++

plot

NDlib provides implementations of several spreading and opinion dynamics models.

The project documentation can be found on ReadTheDocs.

If you use NDlib as support to your research consider citing:

G. Rossetti, L. Milli, S. Rinzivillo, A. Sirbu, D. Pedreschi, F. Giannotti. NDlib: a Python Library to Model and Analyze Diffusion Processes Over Complex Networks. Journal of Data Science and Analytics. 2017. DOI:0.1007/s41060-017-0086-6 (pre-print available on arXiv)

G. Rossetti, L. Milli, S. Rinzivillo, A. Sirbu, D. Pedreschi, F. Giannotti. "NDlib: Studying Network Diffusion Dynamics", IEEE International Conference on Data Science and Advanced Analytics, DSAA. 2017.

Promo Video

Promo

Installation

To install the library just download (or clone) the current project and copy the ndlib folder in the root of your application.

Alternatively use pip:

sudo pip install ndlib

Interactive Dashboard

NDlib includes a browser-based dashboard service for quick, code-free experimentation with diffusion and opinion models.

The dashboard lets you:

  • build or load a network
  • configure model and graph parameters from the UI
  • run simulations in a strict three-step workflow
  • inspect network state, trends, prevalence, and opinion evolution
  • select infected seeds directly from the graph preview for epidemic models
  • use community-aware layouts to expose modular structure
  • separate the visual model builder into epidemic, continuous-opinion, discrete-opinion, and coupled use cases
  • load starter templates such as SIR, Algorithmic Bias, Majority Rule, and a coupled starter layout
  • copy the generated NDQL script or download the generated Python class after saving a custom pipeline
  • build opinion-only custom models without an Infected class when the selected use case does not require one

Run it from the repository root with:

python ndlib/dashboard/server.py

If the package is installed, you can also launch it with the bundled command:

ndlib-dashboard

Once the server starts, open the local URL printed in the terminal.

Configuration view Network view
NDlib dashboard configuration view NDlib dashboard network view

Visual Model Builder

NDlib includes an interactive Visual Model Builder that allows designing custom compartmental models by drag-and-drop using a node-graph workflow. Visual models are compiled to standard Python classes and NDQL (Network Diffusion Query Language) scripts, and can be simulated or deleted directly from the dashboard.

The builder now starts from a use-case selector:

  • Epidemics: discrete compartmental models with infection, threshold, and attribute-driven rules.
  • Continuous Opinions: numeric-opinion layouts centered on numerical checks and continuous-variable style routing.
  • Discrete Opinions: label-based opinion layouts with categorical and stochastic influence blocks.
  • Coupled / Advanced: a mixed workspace that exposes every block for richer custom experiments.

Custom opinion starters now initialize their own statuses directly, so they no longer inherit the epidemic-only Infected requirement from the base diffusion model.

Starter templates are provided for the most common layouts, so you can begin from a working example instead of a blank canvas.

Draggable building blocks include:

  • Status Node: Declares compartmental states (e.g., Susceptible, Infected, Recovered).
  • Node Stochastic: Propagates state change stochastically if neighbors match a status.
  • Node Threshold: Implements fraction-based cascading activation.
  • Edge Stochastic: Evaluates link-level propagation conditions.
  • Count Down: Implements fixed iteration-based delays (e.g., recovery after $D$ ticks).
  • Node Categorical Attribute: Checks categorical node properties (e.g., gender, city).
  • Node Numerical Attribute: Performs numerical checks on node variables (e.g., age ranges).
  • Node Numerical Variable: Compares numeric opinion-like values or attributes against a threshold.
  • Conditional Composition: Composes decision logic gates by nesting condition, if-true, and if-false branches.
Use-case-aware Builder
Use-case-aware Visual Model Builder

The sidebar also includes:

  • a live NDQL preview with a one-click copy action
  • a per-model download button for the generated Python source
  • example templates that can populate the canvas with a starter layout

See the full builder guide in docs/visual_model_builder_opinion_epidemic_guide.md.

Documentation, Tutorials and Online Environments

For examples, tutorials and a complete reference visit the project documentation website on ReadTheDocs.

If you would like to test NDlib functionalities without installing anything on your machine consider using the preconfigured Jupyter Hub instances offered by SoBigData RI.

Jupyter Notebook Tutorial

Interested in an extensive tutorial on NDlib? Check out the official Jupyter Notebooks!

NDlib Overview

Collaborate with us!

NDlib is an active project, any contribution is welcome!

If you like to include your model in NDlib feel free to fork the project, open an issue and contact us.

How to contribute to this project?

Contributing is good, doing it correctly is better! Check out our rules, issue a proper pull request /bug report / feature request.

Do you want to be part of the NDlib community to discuss enhancements, desiderata, bug fix? Join us on Slack!

We are a welcoming community... just follow the Code of Conduct.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndlib-6.0.1.tar.gz (168.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndlib-6.0.1-py3-none-any.whl (234.2 kB view details)

Uploaded Python 3

File details

Details for the file ndlib-6.0.1.tar.gz.

File metadata

  • Download URL: ndlib-6.0.1.tar.gz
  • Upload date:
  • Size: 168.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.8

File hashes

Hashes for ndlib-6.0.1.tar.gz
Algorithm Hash digest
SHA256 8eeb79179409feafb6e0d244ee6ea41465153c79ca1f813829f480efce8af253
MD5 0c56bef6805579240ba6099d30f2142e
BLAKE2b-256 ecb87e427bc0e3366eb227708163ebd32a2b186f689956aaaafaecdccbb2eaa0

See more details on using hashes here.

File details

Details for the file ndlib-6.0.1-py3-none-any.whl.

File metadata

  • Download URL: ndlib-6.0.1-py3-none-any.whl
  • Upload date:
  • Size: 234.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.8

File hashes

Hashes for ndlib-6.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e1fe7426cfb00a1dc0b96c54aadace49744c91259736db9eab56f0e6c171346
MD5 c79005b98fadd99ab2d0eafd0613d141
BLAKE2b-256 a7e343282d7a2f085811aacec5432e95aae1f8453f3e585db1bbacbdb6aa3afc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

6.0.1 This release

2 files

6.0.0

2 files

5.1.1

2 files

5.1.0

2 files

5.0.2

2 files

5.0.0

2 files

4.0.2

2 files

4.0.1

3 files

4.0.0

3 files

3.1.1

3 files

3.1.0

3 files

3.0.1

3 files

3.0.0

3 files

2.1.1

3 files

2.1.0

3 files

2.0.1

3 files

2.0

2 files

1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page