答案1
你可以这样做:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,automata,angles,quotes}
\tikzset{
myneg/.style={
decoration={
markings,
mark=at position 0.5 with
{\draw (0,0) arc (0:180:#1) (0,0) arc (180:360:#1);}
},
postaction=decorate
},
myneg/.default=6pt,
mynode/.style={
draw,
circle,
minimum size=20pt
}
}
\begin{document}
\begin{tikzpicture}
\node[mynode] (a) at (0,0) {$a$};
\node[mynode] (b) at (3,0) {$b$};
\draw
(a) -- (b) node[above=8pt,midway,font=\scshape] {identity};
\begin{scope}[xshift=5cm]
\node[mynode] (a) at (0,0) {$a$};
\node[mynode] (b) at (3,0) {$b$};
\draw[myneg]
(a) -- (b) node[above=8pt,midway,font=\scshape] {not};
\end{scope}
\begin{scope}[yshift=-4cm]
\node[mynode] (a) at (0,2) {$a$};
\node[mynode] (b) at (0,0) {$b$};
\node[mynode] (c) at (0,-2) {$c$};
\node[mynode] (d) at (3,0) {$d$};
\coordinate (aux) at (d.west);
\foreach \Value in {a,b,c}
\draw (\Value) -- (aux);
\path
pic[draw,angle radius=35pt,"\raisebox{20pt}{$\lor$}",
angle eccentricity=1.25]
{angle=a--aux--c};
\path (a) -- (d) node[above=12pt,midway,font=\scshape] {or};
\end{scope}
\begin{scope}[xshift=5cm,yshift=-4cm]
\node[mynode] (a) at (0,2) {$a$};
\node[mynode] (b) at (0,-2) {$b$};
\node[mynode] (c) at (3,0) {$c$};
\foreach \Value in {a,b}
\draw (\Value) -- (c.west);
\path
(a) -- (c)
node[above=12pt,midway,font=\scshape] {and};
\node[left=of c,font=\scshape] {$\land$};
\end{scope}
\end{tikzpicture}
\end{document}
使用修饰(在库的帮助下)获得了否定decorations.markings
,并且“OR”的弧是在angles
库的帮助下生成的。
当然,根据实际的应用程序类型,您可以为节点使用额外的库,例如automata
或chains
。
另一个示例展示了否定和或路径的实际作用:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,automata,angles,quotes}
\tikzset{
myneg/.style={
decoration={
markings,
mark=at position 0.5 with
{\draw (0,0) arc (0:180:#1) (0,0) arc (180:360:#1);}
},
postaction=decorate
},
myneg/.default=6pt,
mynode/.style={
draw,
circle,
minimum size=20pt
}
}
\begin{document}
\begin{tikzpicture}[node distance=1cm and 2cm]
\node[mynode] (b) at (0,0) {$b$};
\node[mynode,above=of b] (a) {$a$};
\node[mynode,below=of b] (c) {$c$};
\node[mynode,right=of b] (d) {$d$};
\node[mynode,above right=of d] (e) {$e$};
\node[mynode,below right=of d] (f) {$f$};
\coordinate (aux) at (d.west);
\foreach \Value in {a,b,c}
\draw (\Value) -- (aux);
\path
pic[draw,angle radius=35pt,"\raisebox{20pt}{$\lor$}",
angle eccentricity=1.25]
{angle=a--aux--c};
\draw[myneg]
(d) -- (e);
\draw[myneg]
(d) -- (f);
\end{tikzpicture}
\end{document}