# Tikz graph costs overlapping

So I have created a very simple graph using TikZ package, but the problem is that the costs and some edges overlap each other. I have to create a multistage graph, so basically I need a way to reallocate the costs, or maybe another solution could came up...

This is the graph example:

begin{tikzpicture}[->,>=stealth',shorten >=2pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[fill=gray,draw=none,text=white]
\tikzstyle{inicio}=[fill=black,draw=none,text=white]
\tikzstyle{final}=[fill=black,draw=none,text=white]

\node[state, inicio] (A)                    {$0$};
\node[state]         (M12) [below right of=A] {$M12$};
\node[state]         (M11) [above of=M12] {$M11$};

\node[state]         (M21) [ right of=M11] {$M21$};
\node[state]         (M22) [ right of=M12] {$M22$};

\path

(A) edge            node {2} (M11)
edge            node {3} (M12)

(M11) edge            node {5} (M21)
edge            node {2} (M22)

(M12) edge            node {5} (M21)
edge            node {2} (M22);

\end{tikzpicture} is this what you are trying to accomplish? \documentclass[border=0.1in]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=2pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[fill=gray,draw=none,text=white]
\tikzstyle{inicio}=[fill=black,draw=none,text=white]
\tikzstyle{final}=[fill=black,draw=none,text=white]

\node[state, inicio] (A)                    {$0$};
\node[state]         (M12) [below right of=A] {$M12$};
\node[state]         (M11) [above of=M12] {$M11$};

\node[state]         (M21) [ right of=M11] {$M21$};
\node[state]         (M22) [ right of=M12] {$M22$};

\path

(A) edge            node {2} (M11)
edge            node {3} (M12)

(M11) edge            node {5} (M21)
edge            node[near end,above right] {2} (M22)

(M12) edge            node[near start,above left] {5} (M21)
edge            node {2} (M22);

\end{tikzpicture}
\end{document}