Skip to content

Instantly share code, notes, and snippets.

@michaeldorner
Last active September 13, 2023 07:31
Show Gist options
  • Save michaeldorner/5ac3a0c51bde24361739901749c311f2 to your computer and use it in GitHub Desktop.
Save michaeldorner/5ac3a0c51bde24361739901749c311f2 to your computer and use it in GitHub Desktop.
Example temporal graph in TikZ
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{backgrounds, positioning}
\usepackage{xcolor}
\definecolor{ACMYellow}{RGB}{255, 214, 0}
\definecolor{ACMOrange}{RGB}{252, 146, 0}
\definecolor{ACMRed}{RGB}{253, 27, 20}
\definecolor{ACMLightBlue}{RGB}{131, 206, 226}
\definecolor{ACMGreen}{RGB}{166, 188, 9}
\definecolor{ACMPurple}{RGB}{101, 1, 107}
\definecolor{ACMDarkBlue}{RGB}{9, 53, 122}
\begin{document}
\begin{center}
\begin{tikzpicture}[show background rectangle]
\draw[thick, , ->] (0,0) node[xshift=-2cm, anchor=west] {$t$} -- (12,0);
\foreach \t in {0, 1, ..., 12} \draw (\t cm,3pt) -- (\t cm,-3pt) node[below] {\t};
\foreach \c [count=\i] in {ACMRed, ACMDarkBlue, ACMGreen, ACMOrange, ACMLightBlue} \draw[\c, ultra thick] (0,\i) node[xshift=-2cm, anchor=west] {Person \i} -- (12,\i);
\foreach \n in {1, 3, 4, 9} \node[draw, ACMRed, circle, fill=ACMRed] (node1\n) at (\n+0.5, 1) {};
\foreach \n in {0, 1, 2, 4, 5} \node[draw, ACMDarkBlue, circle, fill=ACMDarkBlue] (node2\n) at (\n+0.5, 2) {};
\foreach \n in {0, 2, 3, 5, 9, 11} \node[draw, ACMGreen, circle, fill=ACMGreen] (node3\n) at (\n+0.5, 3) {};
\foreach \n in {3, 4, 5, 9, 11} \node[draw, ACMOrange, circle, fill=ACMOrange] (node4\n) at (\n+0.5, 4) {};
\foreach \n in {3, 4, 5, 9} \node[draw, ACMLightBlue, circle, fill=ACMLightBlue] (node5\n) at (\n+0.5, 5) {};
\draw[thick, dashed] (node20) -- (node30);
\draw[thick, dashed] (node11) -- (node21);
\draw[thick, dashed] (node22) -- (node32);
\draw[thick, dashed] (node43) -- (node53);
\draw[thick, dashed] (node44) -- (node54);
\draw[thick, dashed] (node45) -- (node55);
\draw[thick, dashed] (node49) -- (node59);
\draw[thick, dashed] (node19) -- (node39);
\draw[thick, dashed] (node411) -- (node311);
\draw[thick, dashed] (node13) -- (node33);
\draw[thick, dashed] (node14) -- (node24);
\draw[thick, dashed] (node25) -- (node35);
\end{tikzpicture}
\vspace*{2em}
% delta t = 3
\begin{center}
Time-aggregated networks with $\Delta t = 3$
\end{center}
\begin{tikzpicture}[show background rectangle]
\begin{scope}[on grid, xshift=0.5cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n1) -- (n2) -- (n3) -- (n1);
\end{scope}
\begin{scope}[on grid, xshift=3.5cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n4) -- (n5);
\path[draw] (n2) -- (n1);
\end{scope}
\begin{scope}[on grid, xshift=6.5cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\end{scope}
\begin{scope}[on grid, xshift=9.5cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n1) -- (n3) -- (n4) -- (n5);
\end{scope}
\draw[thick, , ->] (0,0) node[xshift=-2cm, anchor=west] {$\Delta t = 3$} -- (12,0);
\foreach \t in {0, 3, ..., 12} \draw (\t cm,3pt) -- (\t cm,-3pt) node[below] {\t};
\end{tikzpicture}
\vspace*{2em}
% delta t = 6
\begin{center}
Time-aggregated networks with $\Delta t = 6$
\end{center}
\begin{tikzpicture}[show background rectangle]
\begin{scope}[on grid, xshift=2cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n1) -- (n2) -- (n3) -- (n1);
\path[draw] (n4) -- (n5);
\end{scope}
\begin{scope}[on grid, xshift=8cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n1) -- (n3) -- (n4) -- (n5);
\end{scope}
\draw[thick, , ->] (0,0) node[xshift=-2cm, anchor=west] {$\Delta t = 6$} -- (12,0);
\foreach \t in {0, 6, ..., 12} \draw (\t cm,3pt) -- (\t cm,-3pt) node[below] {\t};
\end{tikzpicture}
\vspace*{2em}
% delta t = 12
\begin{center}
Time-aggregated network with $\Delta t = 12$
\end{center}
\begin{tikzpicture}[show background rectangle]
\begin{scope}[on grid, xshift=5cm, scale=0.75]
\node[circle, fill=ACMRed] (n1) at (0, 2) {};
\node[circle, fill=ACMDarkBlue] (n2) at (1, 1) {};
\node[circle, fill=ACMGreen] (n3) at (1, 2) {};
\node[circle, fill=ACMOrange] (n4) at (2, 2) {};
\node[circle, fill=ACMLightBlue] (n5) at (2, 1) {};
\path[draw] (n1) -- (n2) -- (n3) -- (n4) -- (n5) -- (n2) -- (n3) -- (n1);
\end{scope}
\draw[thick, , ->] (0,0) node[xshift=-2cm, anchor=west] {$\Delta t = 12$} -- (12,0);
\foreach \t in {0, 12} \draw (\t cm,3pt) -- (\t cm,-3pt) node[below] {\t};
\end{tikzpicture}
\end{center}
\end{document}
@michaeldorner
Copy link
Author

temporal_graphs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment