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}

Simple graph with tikz

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: