Does anyone know how to make this graph in LaTeX?

enter image description here

  • 1
    You can use includegraphics to include the drawing above in your paper or book. It is ok. Jun 9, 2022 at 16:48
  • 1
    This is very similar to your earlier question from a couple of months ago: tex.stackexchange.com/q/641828/15036 Could you adapt the code from that one?
    – Thruston
    Jun 9, 2022 at 17:06
  • Suggestion: Take a few days to go through and try the minimal introduction on ctan.org/pkg/pgf?lang=en ; then spend some time on details you need in the big manual. // You may want to check for \node, \draw , rounded corners, double distance (graphic parameters) to obtain 80-90 % of said sketch.
    – MS-SPO
    Jun 9, 2022 at 17:41

1 Answer 1


Change the value 2 in \resizebox{2\textwidth}{!}{...} to automatically resize the diagram.


\usetikzlibrary{automata, arrows.meta, positioning, shapes}
line width=0.8pt, % make all arrow thicker
state/.style={draw,rounded rectangle,line width=0.4pt},%the state style which has the line width as normal
    % Top row
    \node [state, initial, initial text = {I}] (q0) at (0, 0) {$\lbrace q_1,q_2,q_3,q_4,q_8,q_{14} \rbrace$};
    \node [state, right=2cm of q0] (q1){$\lbrace q_9,q_{10},q_{15},q_{16} \rbrace$};
    \node [state, right=2cm of q1] (q2){$\lbrace q_{11},q_{12} \rbrace$};
    % Middle row
    \node [state, accepting,xshift=0.5cm, below=2cm of q0] (q3){$\lbrace q_2,q_3,q_4,q_7,q_8,q_{14} \rbrace$};
    \node [state, accepting,right=1cm of q3] (q4){$\lbrace q_2,q_3,q_4,q_8,q_{14},q_{19} \rbrace$};
    \node [state, right=1cm of q4] (q5){$\lbrace q_{17},q_{18} \rbrace$};
    % Bottom row
    \node [state, below=2cm of q3.west] (q6){$\lbrace q_5,q_6 \rbrace$};
    \node [state, yshift=-1.75cm, accepting,below=1cm of q4] (q7){$\lbrace q_2,q_3,q_4,q_8,q_{13},q_{14} \rbrace$};
    \node [state, right=10.5cm of q6] (q8){$\emptyset$};
    %Drawing the simple arrows (straight, self loops and curved)
    \path [->]
    (q0) edge[above] node {$0_a$} (q1)
    (q1) edge[above] node {$0_b$} (q2)
    (q5) edge[above] node {$0_c$} (q4)
    (q1) edge[above,bend left] node {$1_d$} (q5)
    (q4.north) edge[right] node {$0_e$} (q4.north|-q2.south)
    (q3) edge[left,bend right] node {$0_f$} (q1.200)
    (q0.south west) edge[left] node {$1_g$} (q0.south west|-q6.north west)
    (q6) edge[left] node {$0_h$} (q3.200)
    (q3.210) edge[right] node {$1_i$} (q6.35)
    (q4) edge[above] node [rotate=20]{missing} (q6)
    (q6) edge[above] node {$1_j$} (q8)
    (q5) edge[right,bend right] node {$1_k$} (q8)
    (q2.340) edge[left] node {$0_l$} (q2.340|-q8.north)
    (q8) edge [loop below] node {\small $0,1$}()
    ; % This semicolon is needed!
    % Drawing the complex lines that have at least one 90 degree turn
    \draw[->, rounded corners] (q7.west) -| node[above, pos=0.25]{$1_m$} (q6.south);
    \draw[->, rounded corners] (q2.east) -- ++(0.5,0) |- node[left, pos=0.25]{$1_n$} (q7.east);
    \draw[->, rounded corners] (q7.south) |- +(6.5,-0.5) |- node[left, pos=0.25]{$0_o$} ++(1,7) -| (q1.north);
  • Thank you. How can i make the edges curve in a rounded way instead of forming a right angle?
    – B612
    Jun 10, 2022 at 16:05
  • 1
    @B612, I have updated the answer. Add rounded corners to the `\draw[...]' commands. I also changed one of the coordinates to keep everything aligned. Jun 10, 2022 at 16:12
  • +1 for this very nice job, despite the fact that OP has already asked many times others to do the job for him and didn't even bother to accept answers.
    – SebGlav
    Jun 10, 2022 at 18:44

Not the answer you're looking for? Browse other questions tagged .