tkz-graph example (A latex graph drawing package)

I recently wanted to use tkz-graph again and found the example below no longer works… here’s an updated version and a copy of the version of tkz-graph I used (old notes are below):


\documentclass{article}
\usepackage{slashbox}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,pdftex]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
%\usepackage[upright]{fourier}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}

\usetikzlibrary{arrows}
\thispagestyle{empty}
\title{Graph}
\begin{document}
\maketitle

\begin{center}
\begin{tikzpicture}[>=latex']
\tikzset{node distance = 5cm}
\GraphInit[vstyle=Normal]
\SetGraphUnit{4}
\Vertex{P}
\EA(P){A}

\tikzset{LabelStyle/.style = {fill=white,sloped}}
\Loop[label=$P$,dir=WE](P)
\Loop[label=$A$,dir=EA](A)
\tikzset{EdgeStyle/.style = {->,bend left}}
\Edge[label=$A$](P)(A)
\Edge[label=$P$](A)(P)
\end{tikzpicture}
\end{center}

\end{document}

tkz-graph
slashbox-sty

The tkz-graph documentation seems very good, but it’s in french. I don’t know french. However I managed to make a little graph with loops and edge labelling. I have to say I’m pretty impressed with the results. Here’s the Latex:

\documentclass{article}
\usepackage{slashbox}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,pdftex]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
%\usepackage[upright]{fourier}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}

\usetikzlibrary{arrows}
\thispagestyle{empty}
\title{Graph}
\begin{document}
\maketitle

\begin{center}
\begin{tikzpicture}[>=latex']
  \tikzset{node distance = 5cm}
  \GraphInit[vstyle=Normal]
  \Vertex{0}
  \EA(0){1}

  \tikzset{LabelStyle/.style = {fill=white,sloped}}
  \tikzset{EdgeStyle/.style = {->,bend left}}
  \Loop[label=$0$,dir=WE](0)
  \Loop[label=$1$,dir=EA](1)
  \Edge[label=$1$](0)(1)
  \Edge[label=$0$](1)(0)
\end{tikzpicture}
\end{center}

\end{document}

And here's how it renders:

That's actually a De Bruijn graph for alphabet size 2, k=2 if I've done it right.

  • new299

    Other odds and ends… You see all those EAs? That means east. So \EA(0){1} means make a new vertex labelled 1 east of the vertex labelled 0. NO, SO, EA and WE are all valid. As are NOEA SOWE etc.