I am using NDlib to try and model an Independent Cascade diffusion process over a graph. I am trying to set some initial seed nodes using config.add_model_parameter('Infected', {0, 10, 100})
(the rest of my code to this point is the same as the tutorial example found here) but I get the error UserWarning: Initial infection missing: a random sample of 5% of graph nodes will be set as infected warnings.warn('Initial infection missing: a random sample of 5% of graph nodes will be set as infected')
when I then run the line model.set_initial_status(config)
. I am not sure how this is happening as in the documentation linked it says the initial infection status can be defined via two options, the first option is what is used in the tutorial and the second is what I am trying to specify instead. Does anyone know why it is not seeming to recognise my initial seed nodes?
The full code I am using is this:
g = nx.erdos_renyi_graph(1000, 0.05, seed=1) model = ep.IndependentCascadesModel(g) config = mc.Configuration() # config.add_model_parameter('fraction_infected', 0) config.add_model_parameter('Infected', {0, 10, 100}) threshold = 0.01 for e in g.edges(): config.add_edge_configuration("threshold", e, threshold) model.set_initial_status(config) # this line triggers the warning
Advertisement
Answer
For ndlib, you should be using add_model_initial_configuration
instead of add_model_parameter
, please look at this example: https://ndlib.readthedocs.io/en/latest/reference/mconf/Mconf.html#status-configuration