Skip to main content

A fast network diffusion library

Project description

CyNetDiff

PyPI version tests docs PyPI - Python Version Ruff Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: MIT DOI SPEC 7 — Seeding pseudo-random number generation

Network diffusion processes aim to model the spread of trends through social networks, represented using graphs. Experimental work with these models usually involves simulating these processes many times over large graphs, which can be computationally very expensive. To address this, CyNetDiff is a Cython module implementing the independent cascade and linear threshold models. Development has been focused on performance, while still giving an intuitive, high-level interface to assist in research tasks. To learn more about these specific models, read this book chapter or the preliminaries page in the documentation.

Quick Start

Installation

pip install cynetdiff

Note: The installation includes a build step that requires having a C++ complier installed.

Basic Usage

We can run models over graphs we define, using pre-defined weighting schemes. Here is a simple example:

import random
import networkx as nx
from cynetdiff.utils import networkx_to_ic_model

# Randomly generate the graph
n = 1_000
p = 0.05
graph = nx.fast_gnp_random_graph(n, p)

# Randomly choose seed nodes
k = 10
nodes = list(graph.nodes)
seeds = random.sample(nodes, k)

# Set the activation probability uniformly and set seeds
model, _ = networkx_to_ic_model(graph, activation_prob=0.2)
model.set_seeds(seeds)

# Run a single diffusion process until completion
model.advance_until_completion()

# Get the number of nodes activated
model.get_num_activated_nodes()

The output from the last line is the number of nodes activated in a single simulation of the model. To get the average number of activated nodes across n_sim = 1_000 simulations, we can replace the last line in the above with the following:

n_sim = 1_000
total = 0.0

for _ in range(n_sim):
    # Resetting the model doesn't change the initial seed set used.
    model.reset_model()
    model.advance_until_completion()
    total += model.get_num_activated_nodes()

avg = total / n_sim

Advanced Usage

See the documentation.

Citation

If you use this code in your research, please use the following citation:

@article{DBLP:journals/pvldb/RobsonRU24,
  author       = {Eilot W. Robson and
                  Dhemath Reddy and
                  Abhishek Kumar Umrawal},
  title        = {CyNetDiff: {A} Python Library for Accelerated Implementation of Network
                  Diffusion Models},
  journal      = {Proc. {VLDB} Endow.},
  volume       = {17},
  number       = {12},
  pages        = {4409--4412},
  year         = {2024},
  url          = {https://www.vldb.org/pvldb/vol17/p4409-umrawal.pdf},
  timestamp    = {Thu, 19 Sep 2024 13:09:38 +0200},
  biburl       = {https://dblp.org/rec/journals/pvldb/RobsonRU24.bib},
  bibsource    = {dblp computer science bibliography, https://dblp.org}
}

Project Status

This project is still considered in a beta stage of development. As such, the API could still change to facilitate easier community adoption.

All feedback is greatly appreciated!

Contributing

Contributions are always welcome! Take a look at the contributing guide.

Project details


Download files

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

Source Distribution

cynetdiff-0.1.18.tar.gz (127.1 kB view details)

Uploaded Source

Built Distributions

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

cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (206.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (213.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

cynetdiff-0.1.18-cp313-cp313-macosx_11_0_arm64.whl (163.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cynetdiff-0.1.18-cp313-cp313-macosx_10_13_x86_64.whl (178.4 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (206.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (212.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

cynetdiff-0.1.18-cp312-cp312-macosx_11_0_arm64.whl (164.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cynetdiff-0.1.18-cp312-cp312-macosx_10_13_x86_64.whl (179.8 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (214.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (219.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686

cynetdiff-0.1.18-cp311-cp311-macosx_11_0_arm64.whl (165.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cynetdiff-0.1.18-cp311-cp311-macosx_10_9_x86_64.whl (178.8 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ i686

cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (214.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (220.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686

cynetdiff-0.1.18-cp310-cp310-macosx_11_0_arm64.whl (164.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

cynetdiff-0.1.18-cp310-cp310-macosx_10_9_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file cynetdiff-0.1.18.tar.gz.

File metadata

  • Download URL: cynetdiff-0.1.18.tar.gz
  • Upload date:
  • Size: 127.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cynetdiff-0.1.18.tar.gz
Algorithm Hash digest
SHA256 a28f1c78ff6cb28a5c11401eb7d73281adb08aff1c330268ee2b99735cf2a967
MD5 bdef6fcd037b83f14f193276d6405a91
BLAKE2b-256 14ba495faf426851011334056fd3b9b1764f3dd316761e21aeaf460c7c76da6f

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 58545d478fa2b94b8d9224a7a99c0dfb637682687d7ec628fb196eb9fc100536
MD5 9e89aa24c5c4b7efeaa860f89fe4426b
BLAKE2b-256 3ed23fb6758ae783fe7205aaa4913f716de258368565a033e75fc5253a6bdc74

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 a92a00ce83f4fc70b61fbb75401e0b6af0e203604083168a9eb8dec13e30e06b
MD5 f2fd88531a90dfe1c7c7dd1745c8ea1f
BLAKE2b-256 4c3deaaccf8edaefb598be4a3a6cf86e4b375ccedc2f294a380a71d07a710c9d

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ebc531b9788fdf0e7dcc3db95f254154401efac40fb82a4f4a39ff0defbb48cf
MD5 1b2d4c3629d99580ab885782a355cd5e
BLAKE2b-256 cf179b2887f554304d05bf1549692f9f14a58708e196c33d918d7b6fad293db4

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4dbe7aa889d7166e27e48191210e59cf29179e0388fe506cee4b16340e99bad8
MD5 3f039e6970c2c1e71ddaede96a90fb90
BLAKE2b-256 ee6823a2d472920f07a32158b9fb7a9c0cd407dac64cf4b49c654cd7668ef4b4

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0582b134c3a72f58be07082ac2f4872ff6e29a352e8bfea1975a3ea8bfec8809
MD5 ed66dbf3b2de579aaa8ac88008478c28
BLAKE2b-256 c9f10a86d256d407f9df26c3e43649c637378203b0e3b976602833871b109655

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7741a20c6d8ce14b3a5fdc22c42970732f4712ab1e1642dbb9719e8067c06ceb
MD5 d03cc370a1ce8c62c6a46372f7f972bc
BLAKE2b-256 deede21b1ac0108f601df174fc5341cf75de1f82a7b49db01408410d86c22fa8

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2c4f5b419cb1f150dfb2e6d413ad487ab16736bcde9d7567f56453d5749a6c0e
MD5 19768a03769e8776e97faa529ca9ce3e
BLAKE2b-256 26e47f8e145413659b694ace155ef0fe33428f955f2c9607f91e0af009ca6b65

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 149c9c9a299904d05c2be8e9651a8a87b25cffe279454c35ee5368a2dc322547
MD5 a36d83801afb00bb79193c0babd06522
BLAKE2b-256 13419cc1bef60a72ab4c5b1e5681dc2649f52d2c4c24042ec58ee1c6e02d41d2

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e00581800234384658a24996ee5e5585906bd3b529a275cc3eb00956452c351
MD5 3d7791c48f6c615b211bfb60f5cd9dbe
BLAKE2b-256 3f222241515284c05e9940c9d92f8ab08ad5d3263c275f1e112d4ab44c8c109a

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5cc4518f1dbbe6265e0ca4c5020cebffd6af8436c8ee3498f8af5cb742ae4841
MD5 404529f592c45ee9f8ece0d92f5cae4c
BLAKE2b-256 04103125008bae24ff9c094ecb673d1d43714ad326924130a352b0118df85138

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7aea56594e583c00317b2ce8c37033337bd7a6546b904530f5259e2621ecfa18
MD5 78f3d34d4f8ca93e4769c59675ffc582
BLAKE2b-256 3ef27d232d0ab4e2d5e6be930c6ec286faae2199c9e37988a124b9af2173d6b4

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1169f879416f11ecee6b22113e0b25b90d1c51df3d854969245d5c397462de90
MD5 ccb4afd286d0eb895aa7abe36ea8f035
BLAKE2b-256 c7302a145687e02ae1f2276ff90a5332cca8d2f111a2c6961598ee7f150c9567

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c9d54435c33fccc7b01a2a8e15b416cb874fe6b09bf06e4493798bd0a0ff065b
MD5 dcc1a354910410e56059a7383a006195
BLAKE2b-256 1715b4fdb92b20f924bc70ecd43e9dd01de31ef1457feb86092f62d9fd2f3039

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 62282d739f52aa35c11cf00905cc062fbc4b2b02b8e09df258f4710e6e610796
MD5 80f3a495c06846127e1bdd6924777021
BLAKE2b-256 1558e039b63fcf7f6bbb9fb12c5764801a5d58d15245f0af839adb2552273d2c

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c6d7bc059b50d832710997d9362b482870247af0acf35b26366cce5b013907a
MD5 b270cdc2013d35a123aab34885b16cd2
BLAKE2b-256 57a6ca02d1afde8c61fc95319cde1869bbbd22fe4932b6a974c375bdbe486970

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5c53c36878b44b3a1a1422f0d814b36ff308b67f1b72bd98c579564a5d91eaca
MD5 0ea952af3ce2c57d8c73cf54c2de75a9
BLAKE2b-256 84252cc7bbdbd414594c31308d8d389c3838df22535533fca41c9670ec5e4073

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c00346dc79d7b070f630d1eacd9871a9238e12fae8e032ff3e180aedcf3ee73
MD5 8794eb65ca017498fe96e13e741ebe14
BLAKE2b-256 07f6056da25d08c2d15129dcdd326b656479c5941da105d6fcdc9e9fc1875f11

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6cd893d1ec214af1af1aabfa2699deb9cf8caca045a5d2dc169a277c35fd8502
MD5 125c6e8192f20c5f77447520a3d90ced
BLAKE2b-256 ee5e36e8251fce08bcb6ebbea9efcce2816296e5776a13f0cba5ab143fd94df8

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d13651ed93bd4908a38316a035b56557ef47226b82f6f091ec00eb6f2c28eade
MD5 137cb0e27be9d580a7fe95bce1240c50
BLAKE2b-256 93373169fcd027227ba61aff5836bd4e19f8e2fd8ab95eaedb7072cb6d7e1887

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7b887540bf144e7e351c3edd18d00c3bcc45d655d6693cf5bb347f061db93a4c
MD5 36ffcfdae21bc5cb735151a8bf3c0011
BLAKE2b-256 1a456203238bc42c3e36ec78898c9ade29e3462fb19525da89ca6e69ec2030d0

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7771a11d6fbaa7c28f018d97dfe2a69fa5333407dda6b1453e26c9985b6d4b95
MD5 77164a272c880d15cf098b2c29fe704d
BLAKE2b-256 5e5994bd86ba5b4d6c16e9f5f3ef4d1f495aa764fac4718d780d23d4032f339d

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 84f9ecd7a8b629f9b1b120a25586a1e74f839a46dfeb4a9359962fdfa9d9b43a
MD5 c2724376ab1045ea59c5c01ce32f8cb3
BLAKE2b-256 35212caaa40783004781dde338cf50ad7896d0131eb076dba2ef1322b200954b

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 208e4744f948ab57ba2f5d71229085973723082b3f26d4b9a770941a484841c6
MD5 cd80fe6f5f653b3a9b19fe0daa2a26dc
BLAKE2b-256 451d16c686abf0539797ddba9e10bba1b6c40d97cb6bc02d0e5454b178c9be9b

See more details on using hashes here.

File details

Details for the file cynetdiff-0.1.18-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cynetdiff-0.1.18-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8a7daacf510bee21bf38f221e4c35c644aa509118ac0b7c42ef405093b2b5ffa
MD5 c8744d5acbbcd429965635077d17909c
BLAKE2b-256 cbc6b9a594faf3f3f0cbf7d6c5e597d4106a7afe7cd38a7bf9f1622e3c2d30e3

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