enter image description here

New to LaTex trying to redraw some diagrams

Any ways of doing that? Is automata a way to go? How do i set the node positions with automata nodes? And how to draw lines like these withh description?

Using tikz pgf

    \node[circle,draw] at (2,0) (q0) {$q_0$}; 
    \node[circle,draw] at (4,0) (q1) {$s_1$}; 
\node at (0,0) (1) {$1$};
\draw (1) -- (q0);
\draw (q0) -- (q1);



\begin{tikzpicture}[>=Latex,shorten >=1pt,auto]
\node[state] (s_0) at(2,0) {$s_0$};
\node[state] (s_1) [above right=of s_0] {$s_1$};
\node[state] (s_2) [below right=of s_1] {$s_2$};
\node[state](s_3) [right=of s_2] {$s_3$};
\node[state] (s_4) [above right=of s_3] {$s_4$};
 %\node[] (aux) [below = of s_4] {};
\node[state,draw=none] (aux) [right = of s_3] {};
\node[state] (s_5) [below right= of aux] {$s_5$};
\node[state](s_6) [right=of s_5] {$s_6$};
\path[->] (s_1) edge node {0} (s_2)
(s_3) edge node {0} (s_5);
\path[->,dashed](s_6) edge[bend right=15] node [swap,pos=.4] {$last_3(w,1)=1$} (s_1);
\draw (0,0)node[left]{2}--(s_0)--(s_2)--(s_3)--(13,0);
\draw (0,0 |- s_1)node[left]{1}--(s_1)--(s_4)--(s_4-| 13,0);
\draw (0,0 |- s_5)node[left]{3}--(s_5)--(s_6)--(s_6-| 13,0);
  • Thanks mate, |- what are these symbols? Never thought about sth like that aux – Rack Cloud Nov 11 '19 at 20:40
  • These symbols are used to place points that are at right angles to two points on the plane on a grid. here, (0.0 |- s_1) means the point that is placed on the vertical of (0.0) and on the horizontal of (s_1). (s_4-| 13.0)means the point located on the horizontal of (s_4) and on the vertical of (13.0). Please, read the page 39 of the 3.1.4b manual. – AndréC Nov 11 '19 at 20:43
  • 1
    I just modified the code so that the distance between the lines is the same. – AndréC Nov 11 '19 at 20:49

This looks like a matrix to me.

 column sep=1.4em,
 execute at begin matrix={\tikzset{name=mat}},
 every arrow/.append style={-stealth},
 execute at end picture={
  \begin{scope}[on background layer]
   \foreach \X in {1,...,\the\numexpr\the\pgfmatrixcurrentrow-1}
     {\draw ([xshift=1em]mat.east|-row\X) -- 
      ([xshift=-1em]mat.west|-row\X) node[left]{\X};} 
 & |[alias=row1]| s_1 \arrow[dr,"0"'] & & & s_4 & &\\
 |[alias=row2]| s_0 & & s_2 & s_3 \arrow[drr,"0"'] & & &\\
  & &  &  & & |[alias=row3]| s_5 & s_6 
  \arrow[uulllll,dashed,bend right=10,"{\text{last}_3(w,1)=1}"']\\

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.