[Tex/LaTex] Shorten Tikz Edges from node to node

tikz-pgf

I am making simple Finite State Machines for a paper. My code is listed below:

%\usetikzlibrary{arrows,automata} in the preamble
\begin{tikzpicture}[>=stealth', auto,node distance=2.75cm]
  \node[state] (start)      {};
  \node[state]         (s1) [right of=start, align=left]  {isProvider\\Enabled};
  \node[state]         (s2) [right of=s1] {};
  \node[state]         (s3) [right of=s2] {};
  \path[->] (start)  edge      node {} (s1)
        (s1) edge              node[text width=1cm,align=center, pos=.4] {requestLocation\\Updates} (s2)
        (s2) edge              node[text width=1cm,align=center, pos=.3 ]{addGps\\StatusListener} (s3);
\end{tikzpicture}

I want to decrease the distance from node start to node s1 to 1cm… but only that distance between nodes. All the other edges should stay 2.75 centimeters. Any ideas or suggestions are appreciated.

Best Answer

You can use the increased functionality of right (and similars) provided by the positioning library (see Section 16.5.3 Advanced Placement Options of the pgf manual):

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata}

\begin{document}
\begin{tikzpicture}[>=stealth', auto,node distance=2.75cm]
  \node[state] (start)      {};
  \node[state]         (s1) [right=1cm of start, align=left]  {isProvider\\Enabled};
  \node[state]         (s2) [right of=s1] {};
  \node[state]         (s3) [right of=s2] {};
  \path[->] (start)  edge      node {} (s1)
        (s1) edge              node[text width=1cm,align=center, pos=.4] {requestLocation\\Updates} (s2)
        (s2) edge              node[text width=1cm,align=center, pos=.3 ]{addGps\\StatusListener} (s3);
\end{tikzpicture}

\end{document}

You need to correct the placement of the labels; as they are right now the text overlaps.