Example: Drawing a graph using the PG 3.0 graphdrawing library

Published 2014-02-28 | Author: Mark Wibrow

PGF 3.0 offers a new convenient and capable library for drawing graphs. The so called graphdrawing library requires compiling via LuaTeX.

The code was written by Mark Wibrow and published on TeX.SE.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Drawing a graph using the PG 3.0 graphdrawing library

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Drawing a graph using the PG 3.0 graphdrawing library
% Author: Mark Wibrow
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={circle, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
    {
        4 -> { 
          3 -> { 1 -> { 5, " " }, 2,2 },
          3 -> { 1, 2, 2 },
          3 -> { 1, 2, 2 }
        } 
    };
\end{tikzpicture}
\end{document}

Comments

Adding comments is currently not enabled.