3

This is my code

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{tkz-graph}
\usetikzlibrary{arrows,positioning,automata}
\PassOptionsToPackage{usernames,dvipsnames,svgnames}{xcolor}

\begin{document}

\begin{tikzpicture}
[>=stealth',shorten >=1pt,node distance=3cm,on grid,initial/.style    ={}]
  \node[state]          (a)                         {$3$};
  \node[state]          (b) [right =of a]           {$4$};
  \node[state]          (c) [above =of b]           {$2$};
  \node[state]          (d) [above =of a]           {$1$};
\tikzset{mystyle/.style={->,double=green}} 
\tikzset{every node/.style={fill=white}} 
\path (a)     edge [mystyle]    node   {$5$} (b)
      (a)     edge [mystyle]    node   {$3$} (c) 
      (b)     edge [mystyle]    node   {$4$} (c)
      (b)     edge [mystyle]    node   {$2$} (d)
      (d)     edge [mystyle]    node   {$1$} (a);
\end{tikzpicture}

\end{document}

This gives me this picture

enter image description here

How do i change my code such that the numbering of edge 2 and edge 3 don't coincide anymore?

Vydai
  • 31
  • I'd change the position of the labels. maybe this post gives you a hint: http://tex.stackexchange.com/questions/57958/how-to-position-the-labels-of-the-path-in-automata – naphaneal Dec 12 '16 at 22:53

1 Answers1

3

Use the pos= option on the arrow labels in the following way:

\path (a)     edge [mystyle]    node   {$5$} (b)
      (a)     edge [mystyle,pos=.3]    node   {$3$} (c) 
      (b)     edge [mystyle]    node   {$4$} (c)
      (b)     edge [mystyle,pos=.3]    node   {$2$} (d)
      (d)     edge [mystyle]    node   {$1$} (a);

The position can be adjusted as necessary, from 0 to 1.