0

I want to change the style of the vertex.

I want all the black filled vertex to be named vertices.

And all the vertices with double circles are now named as well.

That way:

enter image description here

This is the output I had:

enter image description here

This is my code:

\documentclass[12pt]{article}
\usepackage[brazil]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz, tkz-euclide}
\begin{document}    

    \begin{center}
            \begin{tikzpicture}[
        node distance=1.5cm,
        every node/.style={draw, fill, circle, inner sep=1.102pt},
        endnode/.style={fill=none, inner sep=5pt},
        every edge/.style={draw, ->, shorten >=5pt, shorten <=5pt},
        itslabel/.style={draw=none, fill=none, above=0pt, pos=0.5, font=\footnotesize},
        ]
        % position the nodes a..d
        \node (a) [draw=none,fill=none] {I};
        \node (b) [right=of a] {};
        \node (c) [above right=of b] {};
        \node (d) [above right=of c] {};
        \node (e) [right=of d] {};
        \node (f) [right=of e] {};
        \node (g) [right=of f] {};
        \node (gend) [endnode] at (g) {};
        \node (h) [below right=of c] {};
        \node (i) [right=of h] {};
        \node (j) [right=of i] {};
        \node (k) [right=of j] {};
        \node (l) [right=of k] {};
        \node (m) [right=of l] {};
        \node (mend) [endnode] at (m) {};
        \node (n) [below right=of b] {};
        \node (o) [right=of n] {};
        \node (p) [right=of o] {};
        \node (q) [right=of p] {};
        \node (r) [right=of q] {};
        \node (s) [right=of r] {};
        \node (send) [endnode] at (s) {};
        
        
        %[shorten >=1em]    final
        \path (a.center) edge (b) 
        (b) edge node [itslabel, pos=0.38, above=5pt] {\(\varepsilon\)} (c)
        (c.center) edge node [itslabel, pos = 0.4, above = 0.1] {\(\varepsilon\)} (d)
        (d) edge node [itslabel] {\(1\)} (e)
        (e) edge node [itslabel] {\(\varepsilon\)} (f)
        (f) edge [shorten >=1em] node [itslabel] {\(0\)} (g)
        (c) edge node [itslabel, pos = 0.32, below = 0.2] {\(\varepsilon\)} (h)
        (h) edge node [itslabel] {\(0\)} (i)
        (i) edge [shorten >=1em] node [itslabel] {\(\varepsilon\)} (j)
        (j) edge node [itslabel] {\(0\)} (k)
        (k) edge node [itslabel] {\(\varepsilon\)} (l)
        (l) edge [shorten >=1em] node [itslabel] {\(1\)} (m)
        (b) edge node [itslabel, pos = 0.32, below = 0.2] {\(\varepsilon\)} (n)
        (n) edge node [itslabel] {\(0\)} (o)
        (o) edge node [itslabel] {\(\varepsilon\)} (p)
        (p) edge node [itslabel] {\(1\)} (q)
        (q) edge node [itslabel] {\(\varepsilon\)} (r)
        (r) edge [shorten >=1em] node [itslabel] {\(0\)} (s);
        
        \draw[ ->, shorten >=5pt, shorten <=5pt] ($(g) + (0,.1cm)$)
        -- ++(0,.8cm) 
        -| node [itslabel, pos=.2] {\(\varepsilon\)} (b);
        \draw[ ->, shorten >=5pt, shorten <=5pt] ($(m) + (0,-.1cm)$)
        -- ++(0,-2.5cm)
        -| node [itslabel, pos=.2] {\(\varepsilon\)} 
        ($(b) + (-.2cm,0)$);
        \draw[ ->, shorten >=5pt, shorten <=5pt] ($(s) + (0,-.1cm)$)
        -- ++(0,-.63cm)
        -| node [itslabel, pos=.2] {\(\varepsilon\)} (b);
        \end{tikzpicture}
    \end{center}
\end{document}

Can anyone help me to do this?

2
  • 2
    First off, this is not a minimal working example (MWE). Some packages and/or libraries are loaded more than once and many are useless for the purpose of your present graph. This is not your first post here, you should already have payed attention to those rules. Now to stay a bit more on topic, you may need to use the chains library to avoid all those right = of. Then you need to create node styles, using tikzset.
    – SebGlav
    Apr 24 at 15:37
  • 1
    Additionally, when you put code in your question, can you put it all into a code block rather then text so it looks better and can be copy and pasted easier.
    – user245306
    Apr 24 at 16:09

1 Answer 1

1

I didn't want to do too many changes to your code, so I let it like that, not using chains.
I defined endnode differently, and since your request for the normal nodes is not clear enough to me, I tried to add what I thought you needed. Feel free to be more specific if that's not exactly what you want.

vertex styles

\documentclass[12pt]{article}

\usepackage[brazil]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{amsmath}

%automato
\usetikzlibrary{automata, positioning, arrows}
\usetikzlibrary{shapes.geometric}

\tikzset{->,
    >=stealth,
    node distance = 3cm,
    every state/.style={thick, fill=gray!10},
    initial text = $I$,
    auto rotate/.style={auto=right,->,
        to path={let \p1=(\tikztostart),\p2=(\tikztotarget),
            \n1={atan2(\y2-\y1,\x2-\x1)},\n2={\n1-10},\n3={\n1+190}
            in (\tikztostart.\n2) -- (\tikztotarget.\n3) \tikztonodes}}}
        
\begin{document}    

    \begin{center}
            \begin{tikzpicture}[
        node distance=1.5cm,      
        endnode/.style={draw, circle, fill=none, inner sep=5pt, double},
        every edge/.style={draw, ->, shorten >=5pt, shorten <=5pt},
        itslabel/.style={draw=none, fill=none, above=0pt, pos=0.5, font=\footnotesize},
        n1/.style={draw,circle,inner sep=0pt,minimum size=5mm,font=\scriptsize},
        endnode/.style={n1, double, double distance=1.5pt},
        every node/.style={n1},        
        ]
    % position the nodes a..d
    \node (a) [draw=none,fill=none,font=\normalsize] {I};
    \node (b) [right=of a] {$g_1$};
    \node (c) [above right=of b] {$g_2$};
    \node (d) [above right=of c] {$g_3$};
    \node (e) [right=of d] {$g_4$};
    \node (f) [right=of e] {$g_5$};
    \node (g) [draw=none,right=of f] {};
    \node (gend) [endnode] at (g) {$g_6$};
    \node (h) [below right=of c] {};
    \node (i) [right=of h] {};
    \node (j) [right=of i] {};
    \node (k) [right=of j] {};
    \node (l) [right=of k] {};
    \node (m) [draw=none,right=of l] {};
    \node (mend) [endnode] at (m) {};
    \node (n) [below right=of b] {};
    \node (o) [right=of n] {};
    \node (p) [right=of o] {};
    \node (q) [right=of p] {};
    \node (r) [right=of q] {};
    \node (s) [draw=none,right=of r] {};
    \node (send) [endnode] at (s) {};
    
    
    %[shorten >=1em]    final
    \path (a.center) edge (b) 
    (b) edge node [itslabel, pos=0.38, above=5pt] {\(\varepsilon\)} (c)
    (c) edge node [itslabel, pos = 0.4, above = 0.1] {\(\varepsilon\)} (d)
    (d) edge node [itslabel] {\(1\)} (e)
    (e) edge node [itslabel] {\(\varepsilon\)} (f)
    (f) edge [shorten >=1em] node [itslabel] {\(0\)} (g)
    (c) edge node [itslabel, pos = 0.32, below = 0.2] {\(\varepsilon\)} (h)
    (h) edge node [itslabel] {\(0\)} (i)
    (i) edge [shorten >=1em] node [itslabel] {\(\varepsilon\)} (j)
    (j) edge node [itslabel] {\(0\)} (k)
    (k) edge node [itslabel] {\(\varepsilon\)} (l)
    (l) edge [shorten >=1em] node [itslabel] {\(1\)} (m)
    (b) edge node [itslabel, pos = 0.32, below = 0.2] {\(\varepsilon\)} (n)
    (n) edge node [itslabel] {\(0\)} (o)
    (o) edge node [itslabel] {\(\varepsilon\)} (p)
    (p) edge node [itslabel] {\(1\)} (q)
    (q) edge node [itslabel] {\(\varepsilon\)} (r)
    (r) edge [shorten >=1em] node [itslabel] {\(0\)} (s);
    
    \draw[ ->, shorten >=5pt, shorten <=5pt] ($(g) + (0,.1cm)$)
    -- ++(0,.8cm) 
    -| node [itslabel, pos=.2] {\(\varepsilon\)} (b);
    \draw[ ->, shorten >=5pt, shorten <=5pt] ($(m) + (0,-.1cm)$)
    -- ++(0,-2.5cm)
    -| node [itslabel, pos=.2] {\(\varepsilon\)} 
    ($(b) + (-.2cm,0)$);
    \draw[ ->, shorten >=5pt, shorten <=5pt] ($(s) + (0,-.1cm)$)
    -- ++(0,-.63cm)
    -| node [itslabel, pos=.2] {\(\varepsilon\)} (b);
    \end{tikzpicture}
\end{center}
\end{document}
4
  • Yes, that's what I wanted. Thank you. But the figure has now increased in size and didn't fit in my document. Could you please bring the vertices closer together, decreasing the length of the edges?
    – B612
    Apr 24 at 16:26
  • @B612 Maybe try to change node distance = 3cm. Apr 24 at 17:00
  • +1: The code for auto rotate looks pretty sophisticated. Did you come up with it yourself? Apr 24 at 17:09
  • 1
    @Dr. Manuel Kuehner The code for auto rotate was into OP's initial post (edited since).
    – SebGlav
    Apr 24 at 18:13

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.