Skip to content

Commit

Permalink
add simple graph
Browse files Browse the repository at this point in the history
  • Loading branch information
swo committed Dec 13, 2024
1 parent 1ae9cf1 commit a96ad9a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "README.md"
python = "^3.10"
numpy = "^2.2.0"
streamlit = "^1.41.0"
graphviz = "^0.20.3"


[tool.poetry.group.dev.dependencies]
Expand Down
20 changes: 20 additions & 0 deletions ringvax/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import graphviz
import streamlit as st

from ringvax import Simulation


def make_graph(sim: Simulation):
graph = graphviz.Digraph()
for infectee in sim.query_people():
infector = sim.get_person_property(infectee, "infector")

if infector is None:
# this is the index infection
graph.node(str(infectee))
else:
graph.edge(str(infector), str(infectee))

return graph


def app():
st.title("Ring vaccination")

Expand Down Expand Up @@ -78,6 +93,11 @@ def app():
}
s = Simulation(params=params, seed=seed)
s.run()

st.header("Graph of infections")
st.graphviz_chart(make_graph(s))

st.header("Raw results")
st.text(s.infections)


Expand Down

0 comments on commit a96ad9a

Please sign in to comment.