Hello,

I am trying to spread an infection over a random graph where the beta is an

edge property. I want to implement something that could simulate the

lockdown, this is what I wrote:

import matplotlib.pyplot as plt

from graph_tool.all import *

import numpy as np

import random

# graph parameters

N = 6000 # number of vertices

max_count = 100 # time_stamp

beta = 0.01

time_cut = 10

def deg_sample(k):

return np.random.poisson(k)

def evolution(G, beta, counts, perc):

eprop = G.new_edge_property("double")

eprop.a = beta

state = SIState(G, beta=eprop, constant_beta=False)

infected = [state.get_state().fa.sum()]

time = range(counts)

for i in time:

state.iterate_sync()

infected.append(state.get_state().fa.sum())

if (i == time_cut) & (perc != 0):

n = np.array(random.sample(range(len(list(G.edges()))),

int(G.num_edges() * perc/100)))

eprop.a[n] = 0

else:

pass

return infected

G = random_graph(N, lambda: deg_sample(5), directed=False)

G = extract_largest_component(G)

graph_draw(G, output='network_layout.pdf')

x = evolution(G, beta, max_count, 100)

plt.plot(x)

plt.xlabel(r"Time")

plt.ylabel(r"Infectious nodes")

plt.title('infected vs time with all edges cutted at time=%d' % time_cut)

plt.tight_layout()

plt.show()

In evolution I change the beta of all the edges of the graph at a given

timestamp, and I would expect that the infection will stop to spread after I

change the edge property map. But it doesn't happen and the infenction

continue to spread in the network.

I want to understand better what's happening in the SIState fuction.

Regards,

BH.