I am writing a program that will represent the spread of potential infections using graphs. In order to do this I am assigning generational attributes to my nodes, however I am having trouble dereferencing my "gen" attribute. The print statement I set up to compare level and gen (which should be equal to trigger the next step in the program) returns this: check 1, level is: {1: 0} g is: 0. How would I go about dereferencing attributes so that they return only the generation and I can compare this to the generation I am currently working on modeling?
for node in G.nodes(): #check through nodes and find the ones in the current gen
level = nx.get_node_attributes(G, "gen") #get the gen
print("check 1, level is:", level, "g is:", g)
if level == g:
print("check 2")
y = scipy.stats.poisson.rvs(mu=r, size=1) #see how many are infected
N[count] = N[count] + y #how many infected
This is how I assign attributes currently, labeling the number node it is and then assigning it a generation based on a counter
G.add_node(1, gen = count)