我的教授要求我们将 DFA 格式化为包含如下所示的终端节点,但我似乎不知道该怎么做
我的问题是如何在终端 q1 上制作同心圆?
以下是我目前所做的:
\begin{tikzpicture}[roundnode/.style={circle, draw=black!60, fill=white, very thick, minimum size=0.5in}]
\node[roundnode](q1) {$q_1$};
\node[roundnode, right= of q1] (q2) {$q_2$};
\path[thick,-to] (q1) edge [bend left] node[above] {$1$} (q2)
(q1) edge [loop above] node[above] {$0$} (q1)
(q2) edge [loop above] node[above] {$1$} (q2)
(q2) edge [bend left] node[below] {$0$} (q1);
\end{tikzpicture}
生成结果:
除了 q1 上的同心圆之外,这对于所有信用来说已经足够接近了,我该怎么做呢?(请注意,这项作业不是针对我的 LaTex 技能,而是针对我所画的图表,所以这个问题不是请求别人帮我做作业)
理想情况下,我正在寻找一种利用该xnode/.style={...}
属性的解决方案,我想添加一种不同类型的节点terminalnode
,下面是我所指的代码示例:
\begin{tikzpicture}[roundnode/.style={circle, draw=black!60, fill=white, very thick, minimum size=0.5in},
terminalnode/.style={...}]
\node[terminalnode](q1) {$q_1$};
\node[roundnode, right= of q1] (q2) {$q_2$};
\path[thick,-to] (q1) edge [bend left] node[above] {$1$} (q2)
(q1) edge [loop above] node[above] {$0$} (q1)
(q2) edge [loop above] node[above] {$1$} (q2)
(q2) edge [bend left] node[below] {$0$} (q1);
\end{tikzpicture}
这可能吗?如果可以,我该怎么做?
编辑
根据要求,这是我正在处理的完整文件
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{epsf}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand{\Reals}{\mathbb{R}} % real numbers
\newcommand{\Naturals}{\mathbb{N}} % natural numbers
\newcommand{\Integers}{\mathbb{Z}} % integer numbers
\newcommand{\Rationals}{\mathbb{Q}} % rational numbers
\newcommand{\Complexes}{\mathbb{C}} % complex numbers
% math symbols
\newcommand{\IFF}{\mbox{$\Longleftrightarrow$}} % biimplication
\newcommand{\THEN}{\mbox{$\Rightarrow$}} % implication
\begin{document}
\begin{tikzpicture}[roundnode/.style={circle, draw=black!60, fill=white, very thick, minimum size=0.5in}]
\node[roundnode](q1) {$q_1$};
\node[roundnode, right= of q1] (q2) {$q_2$};
\path[thick,-to] (q1) edge [bend left] node[above] {$1$} (q2)
(q1) edge [loop above] node[above] {$0$} (q1)
(q2) edge [loop above] node[above] {$1$} (q2)
(q2) edge [bend left] node[below] {$0$} (q1);
\end{tikzpicture}
\end{document}
答案1
只需添加double
绘制双线的选项。我用%<--
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{epsf}
\usepackage{tikz}
\usetikzlibrary{positioning}
\newcommand{\Reals}{\mathbb{R}} % real numbers
\newcommand{\Naturals}{\mathbb{N}} % natural numbers
\newcommand{\Integers}{\mathbb{Z}} % integer numbers
\newcommand{\Rationals}{\mathbb{Q}} % rational numbers
\newcommand{\Complexes}{\mathbb{C}} % complex numbers
% math symbols
\newcommand{\IFF}{\mbox{$\Longleftrightarrow$}} % biimplication
\newcommand{\THEN}{\mbox{$\Rightarrow$}} % implication
\begin{document}
\begin{tikzpicture}[roundnode/.style={circle, draw=black!60, fill=white, very thick, minimum size=0.5in}]
\node[roundnode,double](q1) {$q_1$};%<-- add "double" option
\node[roundnode, right= of q1] (q2) {$q_2$};
\path[thick,-to] (q1) edge [bend left] node[above] {$1$} (q2)
(q1) edge [loop above] node[above] {$0$} (q1)
(q2) edge [loop above] node[above] {$1$} (q2)
(q2) edge [bend left] node[below] {$0$} (q1);
\end{tikzpicture}
\end{document}
答案2
有一个automata
由 TeXnician 指定的包,其中包含类、state
和,accepting
它们完全可以满足我的要求。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{epsf}
\usepackage{tikz}
\usetikzlibrary{positioning, automata} %<--
\newcommand{\Reals}{\mathbb{R}} % real numbers
\newcommand{\Naturals}{\mathbb{N}} % natural numbers
\newcommand{\Integers}{\mathbb{Z}} % integer numbers
\newcommand{\Rationals}{\mathbb{Q}} % rational numbers
\newcommand{\Complexes}{\mathbb{C}} % complex numbers
% math symbols
\newcommand{\IFF}{\mbox{$\Longleftrightarrow$}} % biimplication
\newcommand{\THEN}{\mbox{$\Rightarrow$}} % implication
\begin{document}
\begin{tikzpicture} %<--
\node[state, accepting](q1) {$q_1$}; %<--
\node[state, right= of q1] (q2) {$q_2$}; %<--
\path[thick,-to] (q1) edge [bend left] node[above] {$1$} (q2)
(q1) edge [loop above] node[above] {$0$} (q1)
(q2) edge [loop above] node[above] {$1$} (q2)
(q2) edge [bend left] node[below] {$0$} (q1);
\end{tikzpicture}
\end{document}