Support weighted graphs for epidemic models
Currently, the SIR model, for instance, samples neighbouring nodes with equal probability. I would like to see an option where edge weights can be used to weight the sampling.
@GiulioRossetti I can implement this for the S*I* models relatively easily. I think the main point is to change:
1 - (1 - beta) ** len(infected_neighbors) as in: https://github.com/GiulioRossetti/ndlib/blob/5493bbb95131afebd9c8c52166bee3d058e7830d/ndlib/models/epidemics/SIModel.py#L88-L90 but actually have it read the edge weights instead. So, something like: 1-np.prod((1 - beta) ** np.array(infected_neighbors_edge_weight)). That would work as now if the weights are all equal to 1:
beta= 0.10
infected_neighbors_edge_weight = [1,1,1]
(1 - (1 - beta) ** np.sum(infected_neighbors_edge_weight) ==
1 - (1 - beta) ** len(infected_neighbors_edge_weight))
But it will reweight things accordingly if infected_neighbors_edge_weight is different to unity. Does it make sense to you?
(EDIT: forgot the word "sense")
I made a fork of andlib on my account (https://github.com/hadjipantelis/ndlib). I think I have a working SIModel at this point, prelim. tests work as expected. I will do a quick pass of the S*I* models I can test on my own and PR it.