3

Anybody who knows how to add multiple objects to edge of automaton? I tried label, but I can add only one label. I need to draw streett automaton, like in this picture:

No more grumpy cats

  • 2
    Welcome to TeX.sx! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are "too localized". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – egreg Apr 17 '13 at 12:24
4

Here's one possibility using decorations:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings}

\begin{document}

\begin{tikzpicture}[mysta/.style={circle,draw,minimum size=25pt},
shorten >=1pt,node distance=3cm,on grid,auto]
\node[mysta] (q0) {};
\node[mysta,right=of q0] (q1) {};
\node[mysta,below=of q0] (q2) {};
\node[mysta,right=of q2] (q3) {};
\draw[<-] (q0) -- +(-30pt,0);
\begin{scope}[decoration={
  markings,
  mark=at position 0.38
  with {\node[circle,draw,fill,inner sep=2pt] {};},
  mark=at position 0.62
  with {\node[circle,draw,fill=white,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) -- node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q0) to[bend left] node[left] {$oc$} (q2);
\draw[postaction=decorate,->] (q1) -- node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q3) to[out=20,in=-20,looseness=8] node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q2) to[out=20,in=-20,looseness=8] node[right] {$oc$} (q2);
\end{scope}
\begin{scope}[decoration={
  markings,
  mark=at position 0.5
  with {\node[circle,draw,fill,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) -- node[above=1pt] {$\top$} (q1);
\draw[postaction=decorate,->] (q1) to[out=20,in=-20,looseness=8] node[right=1pt] {$\top$} (q1);
\end{scope}
\begin{scope}[decoration={
  markings,
  mark=at position 0.5
  with {\node[circle,draw,fill=white,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) to[bend right] node[left=1.5pt] {$\neg co$} (q2);
\draw[postaction=decorate,->] (q2) to[out=200,in=160,looseness=8] node[left=1.5pt] {$\neg co$} (q2);
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

In the solution above, for the paths having two decorations (the black filled circle and the white filled one) the distance between the two decorations was not constant (compare, for example, the distance between the two circles in the diagonal path with the one in the straight downwards path). To correct this, in the following example I use the solution using \pgfdecoratedpathlength proposed by Piotr Wydrych in his answer to How to position multiple decorations on a path while keeping their separation constant? :

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings}

\begin{document}

\begin{tikzpicture}[mysta/.style={circle,draw,minimum size=25pt},
shorten >=1pt,node distance=3cm,on grid,auto]
\node[mysta] (q0) {};
\node[mysta,right=of q0] (q1) {};
\node[mysta,below=of q0] (q2) {};
\node[mysta,right=of q2] (q3) {};
\draw[<-] (q0) -- +(-30pt,0);
\begin{scope}[decoration={
  markings,
  mark=at position 0.5*\pgfdecoratedpathlength-6pt
  with {\node[circle,draw,fill,inner sep=2pt] {};},
  mark=at position 0.5*\pgfdecoratedpathlength+6pt
  with {\node[circle,draw,fill=white,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) -- node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q0) to[bend left] node[left] {$oc$} (q2);
\draw[postaction=decorate,->] (q1) -- node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q3) to[out=20,in=-20,looseness=8] node[right] {$\neg en$} (q3);
\draw[postaction=decorate,->] (q2) to[out=20,in=-20,looseness=8] node[right] {$oc$} (q2);
\end{scope}
\begin{scope}[decoration={
  markings,
  mark=at position 0.5
  with {\node[circle,draw,fill,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) -- node[above=1pt] {$\top$} (q1);
\draw[postaction=decorate,->] (q1) to[out=20,in=-20,looseness=8] node[right=1pt] {$\top$} (q1);
\end{scope}
\begin{scope}[decoration={
  markings,
  mark=at position 0.5
  with {\node[circle,draw,fill=white,inner sep=2pt] {};}
}
]
\draw[postaction=decorate,->] (q0) to[bend right] node[left=1.5pt] {$\neg co$} (q2);
\draw[postaction=decorate,->] (q2) to[out=200,in=160,looseness=8] node[left=1.5pt] {$\neg co$} (q2);
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.