我想改变顶点的样式。
我希望所有黑色填充的顶点都被命名为顶点。
现在所有带有双圆的顶点也都已命名。
那样:
这是我的输出:
这是我的代码:
\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}
有人能帮我做到这一点吗?
答案1
我不想对您的代码做太多更改,所以我让它保持原样,不使用chains
。
我定义了endnode
不同的内容,由于您对普通节点的要求对我来说不够清楚,因此我尝试添加我认为您需要的内容。如果这不是您想要的,请随意更具体一些。
\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}