stocnet / manynet

Many Ways to Make, Manipulate, and Map Myriad Networks
https://stocnet.github.io/manynet/
Other
12 stars 0 forks source link

Fix inconsistencies with how diffusion models are plotted with `graphs()` and `grapht()` #71

Closed henriquesposito closed 4 months ago

henriquesposito commented 5 months ago

The nodes that are susceptible move to becoming 'recovered' immediately without being infected first when plotting difussion models with graphs() and grapht(). The issues could be related to how 'diff_model' objects are converted to 'tidygraph' objects (i.e. information about node attributes related to infected, susceptible, and recovered nodes anymore).

For example:

graphs(play_diffusion(generate_random(to_undirected(to_unnamed(ison_networkers)), with_attr = FALSE), seeds = 10, latency = 0.25, recovery = 0.2, steps = 10))

and

as_tidygraph(play_diffusion(generate_random(to_undirected(to_unnamed(ison_networkers)), with_attr = FALSE), seeds = 10, latency = 0.25, recovery = 0.2, steps = 10))

henriquesposito commented 5 months ago

This has been fixed I believe, the code below appears to plot correctly.

set.seed(1234) net <- generate_random(to_undirected(to_unnamed(ison_networkers)), with_attr = FALSE) .data <- play_diffusion(net, seeds = 10, latency = 0.25, recovery = 0.2, steps = 10) graphs(.data, waves = 10) grapht(.data)

jhollway commented 5 months ago

There still seems to be an issue here. See:

plot(play_diffusion(rando, seeds = 1:2, 
                                 recovery = 0.2, waning = 0.1)) # shows nodes becoming susceptible again
grapht(play_diffusion(rando, seeds = 1:2, 
                                 recovery = 0.2, waning = 0.1)) # nodes don't revert to blue after green
henriquesposito commented 5 months ago

Thank you for the feedback @jhollway , I think I have also addressed this issue with the latest changes, please let me know. See:

graphs(play_diffusion(generate_random(32), seeds = 1:2, recovery = 0.2, waning = 0.1), waves = c(0, 5, 10, 15, 20, 25, 30))