% gr-deBruijn.tex -- the de Bruijn graph B(2,3) : an arc abc -> bcd.
% Each vertex has two arcs in and two arcs out : there is an Eulerian
% cycle ; the bits written on its arcs, in the order of the numbers,
% give a de Bruijn sequence (each word of 4 bits appears once).
% Engine : LuaLaTeX (option lua for \tkzGraphEuler)
\documentclass[border=3mm, convert=false]{standalone}
\usepackage[lua]{tkz-berge}
\begin{document}
\begin{tikzpicture}
  \GraphInit[vstyle=Normal]
  \tikzset{VertexStyle/.append style = {minimum size = 24pt,
                                         fill = cyan!15}}
  \tikzset{LabelStyle/.style = {fill = white, font = \footnotesize,
                                inner sep = 1pt}}
  \tikzset{EulerNumberStyle/.style = {circle, fill = red!80!black,
           text = white, inner sep = 1pt, font = \tiny\bfseries}}
  \Vertex[x=0,y=0]{000}
  \Vertex[x=3,y=2]{001}    \Vertex[x=3,y=-2]{100}
  \Vertex[x=5,y=0]{010}    \Vertex[x=8,y=0]{101}
  \Vertex[x=10,y=2]{011}   \Vertex[x=10,y=-2]{110}
  \Vertex[x=13,y=0]{111}
  \Loop[dir=WE,dist=2cm,style={->},label=0](000)
  \Loop[dir=EA,dist=2cm,style={->},label=1](111)
  \Edge[->,label=1](000)(001)
  \Edge[->,label=0](001)(010)
  \Edge[->,label=1](001)(011)
  \Edge[->,label=0](010)(100)
  \Edge[->,label=1,style={bend left=20}](010)(101)
  \Edge[->,label=0,style={bend left=20}](101)(010)
  \Edge[->,label=1](101)(011)
  \Edge[->,label=0](011)(110)
  \Edge[->,label=1](011)(111)
  \Edge[->,label=0](100)(000)
  \Edge[->,label=1](100)(001)
  \Edge[->,label=0](110)(100)
  \Edge[->,label=1](110)(101)
  \Edge[->,label=0](111)(110)
  \tkzGraphEuler[numbers,pos=.3,start=000]
\end{tikzpicture}
\end{document}
