diff --git a/Analysis/SEIRDS.pdf b/Analysis/SEIRDS.pdf index 07d8447..610aea8 100644 Binary files a/Analysis/SEIRDS.pdf and b/Analysis/SEIRDS.pdf differ diff --git a/Analysis/ode.R b/Analysis/ode.R index 75ac6b1..d275818 100644 --- a/Analysis/ode.R +++ b/Analysis/ode.R @@ -1,7 +1,7 @@ ## Set Working Directory to file directory - RStudio approach setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) -weighted <- 'False' +weighted <- 'True' #conda_install(envname = "r-reticulate", packages="networkx") #conda_install(envname = "r-reticulate", packages="matplotlib") #conda_install(envname = "r-reticulate", packages="pydot") diff --git a/Analysis/prep_model.py b/Analysis/prep_model.py index 05194f9..d72cf23 100644 --- a/Analysis/prep_model.py +++ b/Analysis/prep_model.py @@ -36,6 +36,7 @@ def prep_seirds(weighted): ep_tmp = 0 # counter for epsilon inf_ct = 0 # infection rate counter + recov_ct = 0 # recov rate counter for node in A: color = A.get_node(node).attr.to_dict()['fillcolor'] @@ -50,16 +51,18 @@ def prep_seirds(weighted): in_edges = list(G.in_edges(node)) out_edges = list(G.out_edges(node)) - tmp_S = 1 + tmp_recov = 0 tmp_inf = 0 for source in in_edges: tmp_S = 1 # If previous node was infected, then we are recovered if (color_d[source[0]] == 'red'): - R = R + 1 - tmp_S = 0 - break # No need to check the other nodes + if(weighted == 'False' or not in_edges): + tmp_recov = 1 + else: + recov_ct = recov_ct + 1/len(in_edges) # trivial weighting + recov_ct = recov_ct + tmp_recov for source in out_edges: if (color_d[source[0]] == 'red'): if(weighted == 'False' or not out_edges): @@ -68,26 +71,30 @@ def prep_seirds(weighted): inf_ct = inf_ct + 1/len(out_edges) # trivial weighting inf_ct = inf_ct + tmp_inf S = S + tmp_S - #G[source[0]][node]['weight'] = 3 elif color == 'yellow': color_map.append(color) color_d[node] = color in_edges = list(G.in_edges(node)) + tmp_E = 1 tmp_R = 0 tmp_inf = 0 + tmp_recov = 0 for source in in_edges: # If previous node was infected, then we are recovered if (color_d[source[0]] == 'red'): - tmp_R = 1 tmp_E = 0 + if(weighted == 'False' or not in_edges): + tmp_recov = 1 + else: + recov_ct = recov_ct + 1/len(in_edges) # trivial weighting if (color_d[source[0]] == '' or color_d[source[0]] == 'white'): if(weighted == 'False' or not in_edges): tmp_inf = 1 # add 1 for the inf counter else: inf_ct = inf_ct + 1/len(in_edges) # trivial weighting E = E + tmp_E - R = R + tmp_R + recov_ct = recov_ct + tmp_recov inf_ct = inf_ct + tmp_inf else: color_map.append(color) @@ -116,7 +123,8 @@ def prep_seirds(weighted): # Params beta = (inf_ct)/len(A) # rate of infec delta = 1 # incubation period - gamma_r = R/len(A) # recov rate + #gamma_r = R/len(A) # recov rate + gamma_r = recov_ct/len(A) gamma_d = D/len(A) # death rate mu = D/(I_R+I_D) # fatality ratio epsilon = ep_tmp/len(A) # infected import rate diff --git a/Analysis/segment_network.py b/Analysis/segment_network.py new file mode 100644 index 0000000..2324cca --- /dev/null +++ b/Analysis/segment_network.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 + +import networkx as nx +import matplotlib.pyplot as plt +from collections import OrderedDict +from operator import getitem +import itertools, os, sys + +A = nx.drawing.nx_agraph.to_agraph(nx.drawing.nx_pydot.read_dot("./1_mo_color_DOTFILE.dot")) +A.layout('dot') +#A.draw('tree.png') +A.remove_node('\\n') # Remove "newline" node from newline end of dot file +G=nx.DiGraph(A) + +print(A.get_edge_data(0, 1)) + +subgraph = [] +to_explore = [] +to_explore.append('0') + +for node in to_explore: + for edge in list(G.out_edges(node)): + print(edge) +print() + +for u, v, d in G.edges(data=True): + print(u, v, d['label']) +#for node in A: