tkz-graph

Purpose

The package tkz-graph.sty v 1.00 c is a set of convenient macros, designed to give math teachers (and students) easy access at the programmation of drawing graphs with TikZ. This is the first version uploaded on the CTAN servers and this is why the number version is 1.00 c (c for CTAN) . The kind of graphs that I will present, are sometimes called combinatorial graphs to distinguish them from the graphs of functions. The package tkz-graph.sty is built on top of PGF and its associated front-end, TikZ and is a (La)TeX-friendly drawing package. The aim is to provide a high-level user interface to build graphs relatively simply. I therefore hope that this package provide ideal tools for teachers wanting to offer their students fine documents of maths.This page provides some examples.

News

28/02/2011. This is the version v 1.00 c (c for CTAN) of tkz-graph. This version works with pgf 2.1. Please, send me an email, if you get an error.

How to install

You need to install pgf 2.1 and tkz-graph. You can see the documentation if you have some difficulties to install the package.

I received much valuable advice and guidance on Graph Theory from Rafael Villarroel.

You can see some graphs on the sites :

Exemple 1

Screenshot (click image to enlarge)
Exemple1.
[PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
\documentclass[]{article}
\usepackage[utf8]{inputenc} 
\usepackage[upright]{fourier}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}
     \SetGraphUnit{4}% modifie la distance entre les nodes
     \GraphInit[vstyle=Shade]
     \tikzset{LabelStyle/.style =   {draw,
                                     fill  = yellow,
                                     text  = red}}
     \Vertex{A}
     \EA(A){B}
     \EA(B){C}
     \NO[unit=8](B){D} % unit=8 or \SetGraphUnit{8}
     \Edge[label=1](B)(D)
     \tikzset{EdgeStyle/.append style = {bend left}}
     \Edge[label=4](A)(B)
     \Edge[label=5](B)(A)
     \Edge[label=6](B)(C)
     \Edge[label=7](C)(B)
     \Edge[label=2](A)(D)
     \Edge[label=3](D)(C)
  \end{tikzpicture}
\end{center}
\end{document}

Exemple 2

Screenshot (click image to enlarge)
Exemple1.
[PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX   
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier} 
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[>=latex']
 \SetUpEdge[lw         = 1.5pt,
            color      = orange,
            labelcolor = red!30,
            labelstyle = {draw,sloped}]
  \SetGraphUnit{5}
  \GraphInit[vstyle=Normal]
  \Vertex{P}
  \NOEA(P){B}
  \SOEA(P){M}
  \NOEA(B){D}
  \SOEA(B){C}
  \SOEA(C){L} 
  \tikzset{EdgeStyle/.style={->}}
  \Edge[label=$3$](C)(B)
  \Edge[label=$10$](D)(B)
  \Edge[label=$10$](L)(M)
  \Edge[label=$10$](B)(P)
  \tikzset{EdgeStyle/.style={<->}}
  \Edge[label=$4$](P)(M)
  \Edge[label=$9$](C)(M)
  \Edge[label=$4$](C)(L)
  \Edge[label=$5$](C)(D)
  \Edge[label=$10$](B)(M)
  \tikzset{EdgeStyle/.style={<->,relative=false,in=0,out=60}}
  \Edge[label=$11$](L)(D)
\end{tikzpicture}
\end{center}
\end{document}

Exemple 3

Screenshot (click image to enlarge)
Exemple3.
[PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}    
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
\begin{document}
\begin{tikzpicture}
 \SetVertexNormal[Shape      = circle,
                  FillColor  = orange,
                  LineWidth  = 2pt]
 \SetUpEdge[lw         = 1.5pt,
            color      = black,
            labelcolor = white,
            labeltext  = red,
            labelstyle = {sloped,draw,text=blue}]
 \tikzstyle{EdgeStyle}=[bend left]
 \Vertex[x=0, y=0]{G}
 \Vertex[x=0, y=3]{A} 
 \Vertex[x=3, y=5]{P}
 \Vertex[x=4, y=2]{C}
 \Vertex[x=8, y=3]{Q}
 \Vertex[x=7, y=0]{E}
 \Vertex[x=3, y=-1]{R}
 \Edges(G,A,P,Q,E) \Edges(C,A,Q) \Edges(C,R,G) \Edges(P,E,A)
\end{tikzpicture}
\end{document}

Exemple 4

Screenshot (click image to enlarge)
Exemple4.
[PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX    
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier} 
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{tkz-graph}
\begin{document}
\begin{tikzpicture}[>=stealth']
    \SetGraphUnit{3}
    \tikzset{VertexStyle/.style = {shape        = circle,
                                   fill         = black,
                                   minimum size = 20pt,
                                   text         = white,
                                   draw}}
    \tikzset{TempStyle/.style = {double           = orange,
                                  double distance  = 1pt}}
    \Vertex[L = {\textbf{E}}]{E}
    \NOEA[  L = {\textbf{A}}](E){A}
    \SOEA[  L = {\textbf{D}}](E){D}
    \EA[    L = {\textbf{C}}](D){C}
    \NOEA[  L = {\textbf{B}}](C){B}
    \tikzset{EdgeStyle/.style = {TempStyle, 
                           ->,
                           bend right      = 20}}
    \Edges(A,E,D,C,B)
    \tikzset{EdgeStyle/.style = {TempStyle,
                                 ->,
                                 bend right      = 30}}
    \Edges(B,D)
    \tikzset{EdgeStyle/.style = {TempStyle, 
                                 <-,
                                 bend right      = 20}}
    \Edges(B,A) 
    \tikzset{EdgeStyle/.style = {TempStyle, 
                                 <-,
                                 bend left       = 20}}
    \Edges(A,E,D,C,B)
\end{tikzpicture}
\end{document}