[Tex/LaTex] TikZ: edge should not interfere with other elements in the graph and label positioning

tikz-pgf

I'm quite new to TikZ and I created the following graph:

\begin{tikzpicture}

\node[draw,circle] (n4) at (2, -3) {4};
\node[draw,circle] (n5) at (2, -4) {5};
\node[draw,circle] (n6) at (1, -5) {6};
\node[draw,circle] (n7) at (3, -5) {7};
\node[draw,circle] (n8) at (1, -6) {8};
\node[draw,circle] (n9) at (3, -6) {9};
\node[draw,circle] (n10) at (2, -7) {10};

\draw[->] (n4)--(n5) node[midway, right] {lengthy edge label 1};
\draw[->] (n5)--(n6) node[midway, left] {lengthy edge label 2};
\draw[->] (n5)--(n7) node[midway, right] {lengthy edge label 3};
\draw[->] (n6)--(n8) node[midway, left] {edge label 4};
\draw[->] (n7)--(n9) node[midway, right] {edge label 5};
\draw[->] (n9)--(n10) node[midway, right] {label 6};
\draw[->] (n8)--(n10) node[midway, left] {label 7};

\draw[->] (n10) -| +(4,0) -- +(4,0) node[midway, right]  {edge label 8} |- (n4);    

\end{tikzpicture}

An image of the output can be found here:

Image

It took me quite a while for this graph to build. However, I couldn't come up with a solution for the following questions:

  • Is it possible to set the path of the edge from node 10 to node 4 in such a way that it automatically bypasses the rightmost "inner" label? In the example above I have to adjust the value in \draw to something like +(5,0) so that it doesn't interfere with "lengthy edge label 3", but this seems quite cumbersome if the graph changes frequently
  • How can I place "edge label 8" in the middle of the vertical path segment?
  • Is it possible to increase the distances between the nodes without having to assign new coordinate points to each node?

Any hint is appreciated.

Best Answer

I used another node (c) and I added sme styles.

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[y=1.5cm]

\begin{scope} [every node/.style={draw,circle}]
    \node (n4) at (2, -3) {4};
    \node (n5) at (2, -4) {5};
    \node (n6) at (1, -5) {6};
    \node (n7) at (3, -5) {7};
    \node (n8) at (1, -6) {8};
    \node (n9) at (3, -6) {9};
    \node (n10)at (2, -7) {10}; 
\end{scope}

\begin{scope}[->,every node/.style={ right}]
  \draw (n4)-- node{lengthy edge label 1} (n5);
  \draw (n5)-- node[left] {lengthy edge label 2}(n6)  ;
  \draw (n5)-- node (c) {lengthy edge label 3}(n7) ;
  \draw (n6)-- node[left] {edge label 4}(n8)  ;
  \draw (n7)-- node {edge label 5}(n9)  ;
  \draw (n9)-- node {label 6}(n10) ;
  \draw (n8)-- node[left] {label 7}(n10) ;
\end{scope}

\draw[->] (n10) -| (c.east) coordinate (d)  |-  (n4);
\node [right,anchor=west]  at (n7-|d) {edge label 8} ;   

\end{tikzpicture}
\end{document} 

enter image description here

update

The problem with positioning is to scale the picture. A possibility is to use

\begin{scope} [every node/.style={draw,circle}]
    \path
          ( 2 ,-3)  node  (n4)  {4}
      ++  ( 0 ,-1)  node  (n5)  {5}
      ++  (-1 ,-1)  node  (n6)  {6}
      ++  ( 0 ,-1)  node  (n8)  {8}
      ++  ( 1 ,-1)  node  (n10) {10}
      ++  ( 1 , 1)  node  (n9)  {9}
      ++  ( 0 , 1)  node  (n7)  {7}; 
\end{scope}

and if you don't like the coordinates

 \def\dn{++( 0 ,-1)}   \def\up{++( 0 ,1)}
 \def\rdn{++( 1 ,-1)}  \def\rup{++( 1 ,1)} 
 \def\ldn{++( -1 ,-1)} \def\lup{++( -1 ,1)}  
\begin{scope} [every node/.style={draw,circle}]
    \path
          ( 2 ,-3)  node  (n4)  {4}
              \dn   node  (n5)  {5}
              \ldn  node  (n6)  {6}
              \dn   node  (n8)  {8}
              \rdn  node  (n10) {10}
              \rup  node  (n9)  {9}
              \up   node  (n7)  {7}; 
\end{scope}