View source: R/si_simulation.R
si_simulation | R Documentation |
Initially, all nodes are susceptible status except for a set of r infected nodes selected as source spreaders. At each time step, infected node tries to infect one of its neighbors with given probability.
si_simulation(g, spreaders, prob, layout = layout_nicely(g), plot_iter = F)
g |
Graph object. |
spreaders |
List of initial spreaders (graph vertices). |
prob |
Probability of infecting neighbour. |
layout |
Custom layout, default is layout_nicely. |
plot_iter |
Boolean argument, default FALSE. If TRUE plot every iteration of spreading. |
Number of iterations to infect all nodes.
library(igraphdata) data(karate) spreaders <- voterank(karate, 2) si_simulation(karate, spreaders, prob = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.