Skip to main content

Network Diffusion - a package for simulating spreading phenomena.

Project description

Network Diffusion - Spreading Models in Networks

Licence PyPI version

Tests Builds Docs Codecov FOSSA Status

This Python library provides a versatile toolkit for simulating diffusion processes in complex networks. It offers support for various types of models, including temporal models, multilayer models, and combinations of both.

Short Example

import network_diffusion as nd

# define the model with its internal parameters
spreading_model = nd.models.MICModel(
    seeding_budget=[90, 10, 0],  # 95% act suspected, 10% infected, 0% recovered
    seed_selector=nd.seeding.RandomSeedSelector(),  # pick infected act randomly
    protocol="OR",  # how to aggregate impulses from the network's layers
    probability=0.5,  # probability of infection
)

# get the graph - a medium for spreading
network = nd.mln.functions.get_toy_network_piotr()

# perform the simulation that lasts four epochs
simulator = nd.Simulator(model=spreading_model, network=network)
logs = simulator.perform_propagation(n_epochs=3)

# obtain detailed logs for each actor in the form of JSON
raw_logs_json = logs.get_detailed_logs()

# or obtain aggregated logs for each of the network's layer
aggregated_logs_json = logs.get_aggragated_logs()

# or just save a summary of the experiment with all the experiment's details
logs.report(visualisation=True, path="my_experiment")

Key Features

  • Complex Network Simulation: The library enables users to simulate diffusion processes in complex networks with ease. Whether you are studying information spread, disease propagation, or any other diffusion phenomena, this library has you covered.

  • Temporal Models: You can work with temporal models, allowing you to capture the dynamics of processes over time. These temporal models can be created using regular time windows or leverage CogSnet.

  • Multilayer Networks: The library supports multilayer networks, which are essential for modelling real-world systems with interconnected layers of complexity.

  • Predefined Models: You have the option to use predefined diffusion models such as the Linear Threshold Model, Independent Cascade Model, and more. These models simplify the simulation process, allowing you to focus on your specific research questions.

  • Custom Models: Additionally, Network Diffusion allows you to define your own diffusion models using open interfaces, providing flexibility for researchers to tailor simulations to their unique requirements.

  • Centrality Measures: The library provides a wide range of centrality measures specifically designed for multilayer networks. These measures can be valuable for selecting influential seed nodes in diffusion processes.

  • NetworkX Compatible: The package is built on top of NetworkX, ensuring seamless compatibility with this popular Python library for network analysis. You can easily integrate it into your existing NetworkX-based workflows.

  • PyTorch representation: Network Diffusion offers a plausible converter of the multilayer network to PyTorch sparse representation. That feature can help in deep-learning experiments utilising complex networks (e.g. GNNs).

Package Installation

To install the package, run this command: pip install network_diffusion. Please note that we currently support Linux, MacOS, and Windows, but the package is mostly tested and developed on Unix-based systems.

To contribute, please clone the repo, switch to a new feature branch, and install the environment:

conda env create -f env/conda.yml
conda activate network-diffusion
pip install -e .

Documentation

Reference guide is available here!

Please note that this project is still under development, and the API may vary between versions. Nevertheless, the code is thoroughly commented and the documentation is kept up to date. Another way to become familiar with the operating principles of network_diffusion is to explore some example projects that make use of it:

  • Assessment of using control methods for influence maximisation - v0.17 - repo
  • Generator of a dataset with actors' spreading potentials - v0.16 - repo
  • Influence max. under LTM in multilayer networks - v0.14 - repo
  • Modelling of concurrent spreading and a diffusion in temporal networks - v0.13 - repo
  • Seed selection methods for ICM in multilayer networks - v0.10 - repo

Citing the Library

If you used the package, please consider citing us:

@article{czuba2024networkdiffusion,
  title={Network Diffusion Framework to Simulate Spreading Processes in Complex Networks},
  author={
      Czuba, Micha{\l} and Nurek, Mateusz and Serwata, Damian and Qi, Yu-Xuan
      and Jia, Mingshan and Musial, Katarzyna and Michalski, Rados{\l}aw
      and Br{\'o}dka, Piotr
    },
  journal={Big Data Mining And Analytics},
  volume={7},
  number={3},
  pages={637-654},
  year={2024},
  publisher={IEEE},
  doi = {10.26599/BDMA.2024.9020010},
  url={https://doi.org/10.26599/BDMA.2024.9020010},
}

Particularly if you used the functionality of simulating coexisting phenomena in complex networks, please add the following reference:

@inproceedings{czuba2022coexisting,
  author={Czuba, Micha\l{} and Br\'{o}dka, Piotr},
  booktitle={9th International Conference on Data Science and Advanced Analytics (DSAA)},
  title={Simulating Spreading of Multiple Interacting Processes in Complex Networks},
  volume={},
  number={},
  pages={1-10},
  year={2022},
  month={oct},
  publisher={IEEE},
  address={Shenzhen, China},
  doi={10.1109/DSAA54385.2022.10032425},
  url={https://ieeexplore.ieee.org/abstract/document/10032425},
}

Reporting Bugs

Please report bugs on this board or by sending a direct e-mail to the main author.

About Us

This library is developed and maintained by Network Science Lab from Politechnika Wrocławska / Wrocław University of Science and Technology / Technische Universität Breslau and external partners. For more information and updates, please visit our website or GitHub page.

TODO: add unittests for local_improvement

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

network_diffusion-0.18.0rc20250623143725.tar.gz (106.2 kB view details)

Uploaded Source

Built Distributions

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

network_diffusion-0.18.0rc20250623143725-cp312-cp312-win_amd64.whl (142.0 kB view details)

Uploaded CPython 3.12Windows x86-64

network_diffusion-0.18.0rc20250623143725-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl (157.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

network_diffusion-0.18.0rc20250623143725-cp312-cp312-macosx_10_13_universal2.whl (144.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file network_diffusion-0.18.0rc20250623143725.tar.gz.

File metadata

File hashes

Hashes for network_diffusion-0.18.0rc20250623143725.tar.gz
Algorithm Hash digest
SHA256 9c5a3baee791794fa606a51521a5c40c69b34934c0be485c8bd10c6873df062d
MD5 d35a1756d4eec56754942ca472b25ff3
BLAKE2b-256 54df02f135713e2cdcc0b850edadbd384b15c8cc2876aa19ea72dcd7ac18d685

See more details on using hashes here.

File details

Details for the file network_diffusion-0.18.0rc20250623143725-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for network_diffusion-0.18.0rc20250623143725-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c6aee64661d3c4fa3cd10fc797788e37efd13ef9a82955a84b1bbff4cddef97
MD5 f6a6a8cc82ea3e9c8eb4ada01f59a22d
BLAKE2b-256 7327d6dbc4e3afa82011c0dd439fe46a98df5c0331be241fb3a923dcf64be1cf

See more details on using hashes here.

File details

Details for the file network_diffusion-0.18.0rc20250623143725-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for network_diffusion-0.18.0rc20250623143725-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c6d7d65bb8f5687547660475847f77914cd4d709b33dffb9e08fea919c2141bd
MD5 2b02f995b95bc4af99829b28f0a8f470
BLAKE2b-256 5ea7c1e397092db8d944a4dec932de3842f7046eaae9c936c89e36f23dc3b79a

See more details on using hashes here.

File details

Details for the file network_diffusion-0.18.0rc20250623143725-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for network_diffusion-0.18.0rc20250623143725-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 b6ccd1a627ecaee3e199b67357e10e86f9790881665755f6936d431f1511c127
MD5 6141c4c9bf539fc46732218f090b06f6
BLAKE2b-256 284758c9a2ce86c77dca8c0d2caf3d8efd9d51be0df4599e13bf542cfe48c6ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page