Skip to content

Instantly share code, notes, and snippets.

@spaghetti-source
Created November 28, 2014 09:50
Show Gist options
  • Save spaghetti-source/0fe04b63c08b0fd2fb26 to your computer and use it in GitHub Desktop.
Save spaghetti-source/0fe04b63c08b0fd2fb26 to your computer and use it in GitHub Desktop.
pgfplots network drawing sample
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc}
\usepackage{pgfplots}
\begin{document}
%%%
\tikzstyle{node}=[draw=black,circle,inner sep=0,minimum size=10]
\def \nodes {
1/-5/8.6,
2/ 5/8.6,
3/-10/0,
4/ 0/ 0,
5/10/0,
6/-5/-8.6,
7/5/-8.6%
}
\def \links{
1/3,
1/4,
2/3,
2/4,
2/5,
3/4,
3/7,
4/5,
4/7,
5/7,
6/7%
}
\begin{tikzpicture}[scale=0.5]
\foreach \nodeID/\x/\y in \nodes {
\node [node] (node_\nodeID) at (\x,\y)
{\nodeID};
}
\foreach \u/\v in \links
\draw (node_\u) -- (node_\v);
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment