Skip to content

network-science-lab/lightning-diffusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightning Diffusion

Lightning fast network diffusion library

API

Methods

  • step() - Performs a single step of the diffusion process.
  • run(n_iter: int = -1, verbose: bool=True) - Runs multiple steps of the diffusion process. If n_iter < 0 - runs until termination.
  • reset() - Resets the environment to an initial state, allowing for another simulation.

Attributes

  • state: list - current state of each node
  • iteration: int - number of current iteration
  • terminated: bool - flag signalling the termination of the diffusion model
  • state_space: tuple[str] - Available node states
  • state_summary: dict[str, int] - Current state summary - how many nodes are at each state

Example

import networkx as nx

from lightning_diffusion.models import IndependentCascadeModel

graph = nx.barabasi_albert_graph(1000, 5)
model = IndependentCascadeModel(
    graph,
    infection_probability=0.01,
    initially_infected=0.1,
)

model.run(n_iter=5)

model.state_summary
>>> {'susceptible': 889, 'infected': 0, 'recovered': 111}

Supported Models

IndependenceCascadeModel

Arguments:

  • infection_probability: float - Probability of the infection spreading to each neighbour.
  • initially_infected: float | int - Initially infected number of nodes.

Installation

pip install git+https://github.com/network-science-lab/lightning-diffusion

About

Lightning fast network diffusion library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages