# TikZ, a selfloop without an arrow at the end

In TikZ, within the context of automata, I would like to draw a loop without arrow in order to be able to highlight a path in an automaton, as shown by the following example (which highlight a path without any loop). For standard arc (i.e. arcs between two distinct states) I just draw two arcs:

• first a thick colored arc without any arrow at its end
• second a standard arc

but this does not work for loops.

\usepackage{color}
\usepackage{tikz} \usetikzlibrary{shapes,arrows,automata,backgrounds,matrix,decorations,trees}

\def\ctrref#1{$\constraint{#1}$\index{#1@$\constraint{#1}$|indexuse}}
\def\ctrrefself#1{$\constraint{#1}$}
\def\argument#1{\mathtt{#1}}
\def\constraint#1{\mathtt{#1}}

\definecolor{MyYellowlight}{cmyk}{0,0,0.05,0}

\begin{figure}[!h]
\begin{center}
{\footnotesize
\begin{tikzpicture}[shorten >=1pt,auto,node distance=18mm,semithick]
\node[initial,initial text= ,initial distance=10mm,state,fill=MyYellowlight]  (s00)               {$s_{00}$};
\node[state,fill=MyYellowlight]                               (s11) [right of=s00]    {$s_{11}$};
\node[state,fill=MyYellowlight]                               (s12) [right of=s11]    {$s_{12}$};
\node[state,fill=MyYellowlight]                               (s21) [below of=s12]    {$s_{21}$};
\node[state,fill=MyYellowlight]                               (s31)    [below of=s21] {$s_{31}$};
\node[accepting,state,fill=MyYellowlight]                     (s41) [below of=s31]    {$s_{41}$};
\node[accepting,state,fill=MyYellowlight]                     (s51)    [left of=s41]  {$s_{51}$};
\node[accepting,state,fill=MyYellowlight]                     (s61)    [left of=s51]  {$s_{61}$};
\path
(s00) edge [line width=4pt,orange!70]             node {$\bf 3$} (s11)
(s00) edge [->,>=stealth']                        node {} (s11)
(s11) edge [line width=4pt,orange!70]             node {$\bf 3$} (s12)
(s11) edge [->,>=stealth']                        node {} (s12)
(s12) edge [->,>=stealth',loop above]             node {$3$} (s12)
(s12) edge [->,>=stealth']                        node [left] {$4$} (s21)
(s12) edge [->,>=stealth',bend left]              node [right, very near end] {$5$} (s31)
(s12.325) edge [line width=4pt,orange!70,bend left]   node {$\bf 6$} (s41)
(s12.325) edge [->,>=stealth', bend left]         node {} (s41)
(s21) edge [->,>=stealth']                        node [left] {$5$} (s31)
(s21) edge [->,>=stealth',bend right]             node [left] {$6$} (s41)
(s31) edge [->,>=stealth']                        node [left] {$6$} (s41)
(s41) edge [->,>=stealth',loop right]             node {$6$} (s41)
(s41) edge [->,>=stealth']                        node [above] {$7$} (s51)
(s41) edge [line width=4pt,orange!70,bend left]       node {$\bf 8$} (s61)
(s41) edge [->,>=stealth', bend left]             node {} (s61)
(s51) edge [->,>=stealth']                        node [above] {$8$} (s61);
\end{tikzpicture}
}
\end{center}
\caption{Automaton of the \ctrrefself{increasing\_global\_cardinality} constraint of the {\bf Example} slot: the path corresponding to the solution $\langle {\color{orange!70}\bold{3}},{\color{orange!70}\bold{3}},{\color{orange!70}\bold{6}},{\color{orange!70}\bold{8}}\rangle$ is depicted by thick orange arcs}
\label{fig:increasing_global_cardinality1}
\end{figure}

-
Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}). –  Claudio Fiandrino Oct 21 '12 at 12:24
Notice that it is always preferable to post complete minimal working examples rather than code snippets because this helps people to answer you. –  Claudio Fiandrino Oct 21 '12 at 12:25
Also related : tex.stackexchange.com/questions/73220/… –  percusse Oct 21 '12 at 12:34

You can use a separate path to draw the highlight, and change the every loop style for that path to draw a thick coloured line, and then draw the arrow afterwards. I also added some styles for the highlight lines and arrows.

Minimal example:

\documentclass{article}
\usepackage{tikz,siunitx}
\usetikzlibrary{automata,arrows}
\begin{document}

\begin{tikzpicture}[shorten >=1pt,auto,node distance=18mm,semithick,
highlight/.style={line width=4pt,orange!70},
MyArrow/.style={->,>=stealth'}]
\node[initial,initial text= ,initial distance=10mm,state]  (s00)  {$s_{00}$};
\node[state] (s11) [right of=s00]    {$s_{11}$};
\path [every loop/.style={highlight}, % draw highlights
highlight]
(s11) edge [loop above]  (s11)
(s00) edge node {$\mathbf{3}$} (s11);
\path % draw normal paths
(s00) edge [MyArrow]            node {} (s11)
(s11) edge [MyArrow,loop above]  node {$3$} (s11);
\end{tikzpicture}
\end{document}


### Note

Don't use \bf, \it etc. as they are deprecated. use \bfseries, \itshape instead, see Does it matter if I use \textit or \it, \bfseries or \bf, etc. and Will two-letter font style commands (\bf, \it, …) ever be resurrected in LaTeX?. For mathmode however, use \mathbf{...}

-
Thanks, works well. –  Nicolas Beldiceanu Oct 21 '12 at 12:55
@NicolasBeldiceanu if this has resolved the issue, please consider accepting the answer (after a suitable amount of time, perhaps to allow other answers) by clicking on the green check mark. Welcome to the group :) –  cmhughes Oct 22 '12 at 2:33