Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created May 9, 2026 04:07
Show Gist options
  • Select an option

  • Save abikoushi/eea5e8b3d3253a8255073111ffdea427 to your computer and use it in GitHub Desktop.

Select an option

Save abikoushi/eea5e8b3d3253a8255073111ffdea427 to your computer and use it in GitHub Desktop.
DAG using TikZ
%Kucharski A, Russell T, Diamond C et al.
%Early dynamics of transmission and control of COVID-19: a mathematical modelling study
%The Lancet Infectious Diseases, 2020; 20, 553-558
%https://www.thelancet.com/article/S1473-3099(20)30144-4/fulltext
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,fit,backgrounds}
\begin{document}
\begin{tikzpicture}[
>=Latex,
node distance=12mm and 18mm,
every node/.style={font=\small},
comp/.style={
draw,
rectangle,
minimum width=10mm,
minimum height=6mm
}
]
%--------------------------------
% Source
%--------------------------------
\node (S) {$S$};
%--------------------------------
% W chain
%--------------------------------
\node[right=3cm of S] (E1W) {$E_{1W}$};
\node[right=of E1W] (E2W) {$E_{2W}$};
\node[right=of E2W] (I1W) {$I_{1W}$};
\node[right=of I1W] (I2W) {$I_{2W}$};
\node[above right =of E2W] (QW) {$Q_W$};
\node[above right=of QW, comp] (CW) {$C_W$};
\node[right=of QW, comp] (DW) {$D_W$};
%--------------------------------
% T chain
%--------------------------------
\node[below=3cm of E1W] (E1T) {$E_{1T}$};
\node[right=of E1T] (E2T) {$E_{2T}$};
\node[right=of E2T] (I1T) {$I_{1T}$};
\node[right=of I1T] (I2T) {$I_{2T}$};
\node[below right=of E2T] (QT) {$Q_T$};
\node[below right=of QT, comp] (CT) {$C_T$};
\node[right=of QT, comp] (DT) {$D_T$};
%--------------------------------
% Background boxes
%--------------------------------
\begin{scope}[on background layer]
\node[
draw,
rounded corners,
inner sep=8mm,
fit=(S)(E1W)(E2W)(I1W)(I2W)(QW)(CW)(DW),
label=above:{Wuhan population}
] {};
\node[
draw,
rounded corners,
inner sep=8mm,
fit=(E1T)(E2T)(I1T)(I2T)(QT)(CT)(DT),
label=below:{International travelers from Wuhan}
] {};
\end{scope}
%--------------------------------
% Edges W
%--------------------------------
\draw[->] (E1W) -- (E2W);
\draw[->] (E2W) -- (I1W);
\draw[->] (I1W) -- (I2W);
\draw[->] (E2W) -- (QW);
\draw[->] (E2W) -- (DW);
\draw[->] (QW) -- (CW);
\draw[->] (I1W) to[bend left=20] (E1W);
\draw[->] (I2W) to[bend left=20] (E1W);
%--------------------------------
% Edges T
%--------------------------------
\draw[->] (E1T) -- (E2T);
\draw[->] (E2T) -- (I1T);
\draw[->] (I1T) -- (I2T);
\draw[->] (E2T) -- (QT);
\draw[->] (E2T) -- (DT);
\draw[->] (QT) -- (CT);
%--------------------------------
% Cross edges
%--------------------------------
\draw[->] (S) -- (E1W);
\draw[->] (S) -- (E1T);
\draw[->] (I1W) to[bend left=15] (E1T);
\draw[->] (I2W) to[bend left=15] (E1T);
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment