ndlib icon indicating copy to clipboard operation
ndlib copied to clipboard

It is not possible to set the propagation probability of edges (u,v) and (v,u) at the same time in an undirected graph

Open zzzkhj opened this issue 7 months ago • 1 comments

Describe the bug model = ep.IndependentCascadesModel(graph) config = mc.Configuration()

for u, v in graph.edges():
    config.add_edge_configuration("threshold", (u, v), 1/graph.degree(v))
    config.add_edge_configuration("threshold", (v, u), 1/graph.degree(u))

When I try to set the propagation probability to 1 part of the degree with the above code, I get the keyerror. Because when I look at the ND code, I find that the propagation probability set by default is 1 out of degree, for example, when you activate v, the probability is 1 out of the degree of u. I expected to accomplish my purpose with the above settings, but something went wrong and only the default propagation probability was used.

KeyError Traceback (most recent call last) Cell In[25], line 18 16 config.add_model_initial_configuration("Infected", S) 17 model.set_initial_status(config) ---> 18 print(model.params['edges']['threshold'][(0, 7)]) 19 break 20 # print(model.initial_status.values()) 21 # print(1, np.array(model.initial_status.values()).nonzero()) 22 23 #

KeyError: 'threshold'

To Reproduce Steps to reproduce the behavior:

  • NDlib version: 5.1.1
  • Operating System: Ubuntu 20.04.5 LTS
  • Python version: 3.8.10
  • Version(s) of NDlib required libraries networkx: 3.0

zzzkhj avatar May 22 '25 03:05 zzzkhj

sorry, 1 part of the degree is 1/in_degree(v), out of the degree of u is 1/in_degree(u) with edge (u,v).

zzzkhj avatar May 22 '25 03:05 zzzkhj