Home » programming » Constructing a simple graph using Tikz

# Constructing a simple graph using Tikz

We start by creating a vertex s and then we add the new vertices using their relative position (east (EA), south (SO), north (NO), west (WE)). The relative positions can also be combined (NOEA for instance). Then, we draw the edges.

\usepackage{tkz-graph}

\begin{figure}[b]
\centering
\begin{tikzpicture}
\SetUpEdge[lw         = 1pt,
color      = black,
labelcolor = white]
\SetVertexNoLabel
\GraphInit[vstyle=Normal]
\SetGraphUnit{3}
\tikzset{VertexStyle/.append  style={fill}}
\Vertex{s}
\EA(s){a}  \NO(a){aa} \EA(aa){b} \SO(b){c}
\EA(c){d}
\Edge[label={$\{g_2\}$}, labelstyle={above}](s)(a)
\Edge[label={$\{g_1, g_2\}$}, labelstyle={left}](a)(aa)
\Edge[label={$\{g_1, g_2, g_3\}$}, labelstyle={above}](aa)(b)
\Edge[label={$\{g_2\}$}, labelstyle={sloped, above}](a)(b)
\Edge[label={$\{g_1,g_2,g_3\}$}, labelstyle={right}](b)(c)
\Edge[label={$\{g_3\}$}, labelstyle={above}](c)(d)
\end{tikzpicture}
\caption{Integrated Graph after inserting  $g_3$ \label{fig:igraph_3}}
\end{figure}