Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support weighted graphs for epidemic models #207

Open
pulquero opened this issue Sep 22, 2021 · 2 comments
Open

Support weighted graphs for epidemic models #207

pulquero opened this issue Sep 22, 2021 · 2 comments

Comments

@pulquero
Copy link

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.

@hadjipantelis
Copy link

hadjipantelis commented Dec 6, 2024

@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:

if eventp < 1 - (1 - self.params["model"]["beta"]) ** len(
infected_neighbors
):
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")

@hadjipantelis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants