tkz-graph

The package tkz-graph.sty v 2.7c is a set of convenient macros for drawing graphs. 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. This page provides some examples.

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

You can see some graphs on the sites :

Graph 1 : Königsberg

Konigsberg
Graph 1 : Königsberg [PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
\documentclass[]{article}
\usepackage[utf8]{inputenc} 
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[node distance   = 4 cm]
     \GraphInit[vstyle=Shade]
     \tikzset{LabelStyle/.style =   {draw,
                                     fill  = yellow,
                                     text  = red}}
     \Vertex{A}
     \EA(A){B}
     \EA(B){C}
     \tikzset{node distance   = 8 cm}% modifie la distance entre les nodes
     \NO(B){D}
     \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}

Graph 2

Gr 2
Graph 2 : [PDF] [TEX]
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,pdftex]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[>=latex']
 \SetUpEdge[lw         = 1.5pt,
            color      = orange,
            labelcolor = red!30,
            labelstyle = {draw,sloped}]
  \tikzset{node distance = 5cm}
  \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}
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX

Graph 3

Graph 3
Graph 3 : [PDF] [TEX]
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\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}

Graph 4

Gr 4
Graph 4 : [PDF] [TEX]
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,pdftex]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[>=stealth']
    \tikzset{node distance = 3cm}
    \tikzstyle{VertexStyle}=[shape        = circle,
                             fill         = black,
                             minimum size = 20pt,
                             text         = white,
                             draw]
    \tikzstyle{TempStyle}=[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}
    \tikzstyle{EdgeStyle}=[TempStyle,
                           ->,
                           bend right      = 20]
    \Edges(A,E,D,C,B)
    \tikzstyle{EdgeStyle}=[TempStyle,
                           ->,
                           bend right      = 30]
    \Edges(B,D)
    \tikzstyle{EdgeStyle}=[TempStyle,
                           <-,
                           bend right      = 20]
    \Edges(B,A) 
    \tikzstyle{EdgeStyle}=[TempStyle,
                           <-,
                           bend left       = 20]
    \Edges(A,E,D,C,B)
\end{tikzpicture}
\end{document}
% Author : Alain Matthes
% Encoding : UTF8
% Engine : PDFLaTeX
Alain Matthes — al.ma@mac.com — last modification: « 01/03/2009 » with TextMate Hosted by WebFaction.