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}
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.