Init work on epidem model prep

This commit is contained in:
Noah L. Schrick 2023-04-28 16:31:56 -05:00
parent 9b08949478
commit 56f6a9bb90
3 changed files with 1830 additions and 0 deletions

File diff suppressed because it is too large Load Diff

56
Analysis/prep_model.py Normal file
View File

@ -0,0 +1,56 @@
#!/usr/bin/python3
import networkx as nx
import matplotlib.pyplot as plt
from collections import OrderedDict
from operator import getitem
import itertools, os
# AGraph preserves attributes, networkx Graph does not.
# Many of the desired functions are in networkx.
# So import AGraph to keep attributes, then convert to Networkx.
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)
color_map = []
color_d = {}
node_pos = {}
# Compartments
S = 0
I = 0
E = 0
R = 0
D = 0
# Params
beta = 0
delta = 0
gamma_r = 0
gamma_d = 0
mu = 0
epsilon = 0
omega = 0
for node in A:
color = A.get_node(node).attr.to_dict()['fillcolor']
str_pos = A.get_node(node).attr.to_dict()['pos']
coords = str_pos.split(',')
x = coords[0] # layout for draw function
y = coords[1]
node_pos[node] = float(x), float(y)
if color is None or color == '':
color_map.append("white")
color_d[node] = color
in_edges = list(G.in_edges(node))
elif color == 'yellow':
color_map.append(color)
color_d[node] = color
in_edges = list(G.in_edges(node))
else:
color_map.append(color)
color_d[node] = color
in_edges = list(G.in_edges(node))

BIN
Analysis/tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB