Address this bug report first: https://sourceforge.net/p/pgf/bugs/524/
The following latex code produces an incorrect result. In the attachement you will find the latex code, a PDF of the expected result, and a PDF of the actual (bugged) result.
%\RequirePackage{luatex85}
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{a4wide}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing,quotes}
\usegdlibrary{layered}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[rounded corners]
\graph [layered layout,
minimum height layer assignment,
edge quotes={fill=white,inner sep=1pt,font=\scriptsize},
nodes={circle,draw,inner sep=.2,outer sep=0, minimum size=.45cm},
level sep=1.5cm, %vertical distance between layers
sibling distance=2cm, %distance between nodes of the same connected component in the same layer
component sep=0cm %distance between connected components
]
{[edge={pos=.45}]
%COMMENTING OUT THE FOLLOWING LINES FIXES THE BUG:
0/"$r$";
13/"$t$";
2/"$u_{2}$";
3/"$u_{3}$";
4/"$u_{4}$";
5/"$u_{5}$";
6/"$u_{6}$";
7/"$u_{7}$";
8/"$u_{8}$";
9/"$u_{9}$";
10/"$u_{10}$";
11/"$u_{11}$";
12/"$u_{12}$";
% ^END COMMENT
0 ->["$0$",bend left=0] 2,
0 ->["$1$",bend left=0] 3,
2 ->["$0$",bend left=0] 4,
2 ->["$1$",bend left=0] 5,
3 ->["$0$",bend left=0] 6,
3 ->["$1$",bend left=0] 4,
4 ->["$0$",bend left=0] 7,
4 ->["$1$",bend left=0] 8,
5 ->["$0$",bend left=0] 9,
5 ->["$1$",bend left=0] 7,
6 ->["$0$",bend left=0] 8,
6 ->["$1$",bend left=0] 9,
7 ->["$0$",bend left=0] 10,
7 ->["$1$",bend left=0] 11,
8 ->["$0$",bend left=0] 12,
8 ->["$1$",bend left=0] 10,
9 ->["$0$",bend left=0] 11,
9 ->["$1$",bend left=0] 12,
10 ->["$1$",bend left=-80] 13,
10 ->["$4$",bend left=-60] 13,
11 ->["$0$",bend left=-80] 13,
11 ->["$3$",bend left=-60] 13,
12 ->["$2$",bend left=-80] 13,
12 ->["$5$",bend left=-60] 13,
};
\end{tikzpicture}
\caption{Bugged}
\end{figure}
\end{document}
Notice that vertex 13 is placed in layer 1. This is because the number of incoming edges into vertex 13 incorrectly equals 0! One can verify this by adding:
print("node: " .. node.name .. " nrIncomingEdges: " .. #edges)
immediately after local edges = node:getIncomingEdges() in NodeRankingMinimumHeight.lua. This prints:
node: 13 nrIncomingEdges: 0
By commenting out the lines indicated in the .tex file, the issue seems to be fixed.
Oddly, substituting this:
by this (i.e. simply reordering) also fixes the problem: