Tikz Petri-Net - 如何在边缘上放置非标记?

Tikz Petri-Net - 如何在边缘上放置非标记?

我需要在边旁边画一个“非 A”标记。Tikz -> petri 中是否有内置函数来实现该功能?我看到标记前面有一个点,表示否定。(现在找不到,明天再找)。但是 tikz 文档对于 petri 库来说相当简短。每个 tikz 库是否有单独的文档?

petri-net with store and a type based transition for either A-tokens or not-A-tokens

是否可以控制存储中多个标记的间距(此处命名为:“源”)?我确实找到了一种手动方法,但感觉这不是应该这样做的方式:在 tikz/petri 中放置代币

\documentclass{scrbook}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,decorations,automata,petri}

\begin{document}
\begin{tikzpicture}[->,circle,inner sep=0mm,minimum size=6mm,
label distance=0mm,node distance=10mm,thick,>=stealth',auto,
%styles
Store/.style={ellipse,draw=black,thick,minimum height=10mm,minimum width=17mm},
store/.style={ellipse,draw=black,thick,minimum height=6mm,minimum width=9mm},
place/.style={circle,draw=black,thick,},
trans/.style={rectangle,draw=black,thick},
edgetoken/.style={above=1mm,circle,fill=black,minimum size=2.5mm}]

\node (source)  [Store, label={left:source}] at (0,0) {}
[children are tokens]
child {node [token] {A}}
child {node [token] {B}}
child {node [token] {C}};

\node (t1)  [trans, right=of source]            {$t_{1}$}
edge [<-] node[edgetoken]{} (source);

\node (A)   [store, right=of t1, label={right:A}] {}
[children are tokens]
child {node [token] {A}}    
edge [<-] node[token,above]{A} (t1);    % token A

\node (not_B)   [store, below=of A, label={right:not A}] {}
[children are tokens]
child {node [token] {B}}
child {node [token] {C}}
edge [<-] node[token,above]{BC} (t1);   % not token A
\end{tikzpicture}

\end{document}

答案1

这是对您的第二个问题的回答,因为我理解这个问题;)。

我已更新语法以使用当前推荐的几个库的最新版本,并通过不加载示例不需要的一些库来将其最小化。显然,请在原始文档中恢复这些库,因为您可能在那里需要它们。

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{arrows.meta,shapes.geometric,positioning,petri}

\begin{document}
\begin{tikzpicture}
  [
    ->,
    circle,
    inner sep=0mm,
    minimum size=6mm,
    label distance=0mm,
    node distance=10mm,
    thick,
    >={Stealth[]},
    auto,

我稍微重新组织了样式,因为我发现使用清晰的样式层次结构更容易,例如,一大堆样式需要一些设置,一个子集还需要一些设置,而该子集中的一个需要额外的特定设置或其他设置。我发现这更容易维护和保持一致。

    basic/.style={draw=black, thick},
    store/.style={ellipse, basic, minimum height=6mm, minimum width=9mm},
    Store/.style={store, minimum height=10mm, minimum width=17mm},
    place/.style={circle, basic,},
    trans/.style={rectangle, basic},
    edgetoken/.style={above=1mm, circle, fill=black, minimum size=2.5mm},

当我们需要更大的节点时,我们需要一种新的样式。我们使用every tokentoken distance来稍微扩大和分散标记来实现这一点。

    storage/.style={every token/.append style={minimum size=10pt}, token distance=12.5pt}
  ]

我们将新的风格应用于storage所有的孩子source

  \node (source) [Store, label={left:source}] at (0,0) {} [children are tokens, storage] child {node [token] {A}} child {node [token] {B}} child {node [token] {C}};

我们不希望它出现在下一个节点或者边缘。

  \node (t1) [trans, right=of source] {$t_{1}$} edge [<-] node[edgetoken]{} (source);

我们在这里将它应用到子项上,而不是边缘标记。

  \node (A) [store, right=of t1, label={right:A}] {} [children are tokens] child [storage] {node [token] {A}} edge [<-] node[token,above]{A} (t1); 

我们在这里将它应用于的子项,not_B但不应用于边缘上的标记,通过使用花括号来包含的范围storage

  \node (not_B) [store, below=of A, label={right:not A}] {} [children are tokens] {[storage] child {node [token] {B}} child {node [token] {C}}} edge [<-] node[token,above]{BC} (t1);   % not token A
\end{tikzpicture}

\end{document}

结果:

larger, spacier tokens

完整代码:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{arrows.meta,shapes.geometric,positioning,petri}

\begin{document}
\begin{tikzpicture}
  [
    ->,
    circle,
    inner sep=0mm,
    minimum size=6mm,
    label distance=0mm,
    node distance=10mm,
    thick,
    >={Stealth[]},
    auto,
    basic/.style={draw=black, thick},
    store/.style={ellipse, basic, minimum height=6mm, minimum width=9mm},
    Store/.style={store, minimum height=10mm, minimum width=17mm},
    place/.style={circle, basic,},
    trans/.style={rectangle, basic},
    edgetoken/.style={above=1mm, circle, fill=black, minimum size=2.5mm},
    storage/.style={every token/.append style={minimum size=10pt}, token distance=12.5pt}
  ]

  \node (source) [Store, label={left:source}] at (0,0) {} [children are tokens, storage] child {node [token] {A}} child {node [token] {B}} child {node [token] {C}};

  \node (t1) [trans, right=of source] {$t_{1}$} edge [<-] node[edgetoken]{} (source);

  \node (A) [store, right=of t1, label={right:A}] {} [children are tokens] child [storage] {node [token] {A}} edge [<-] node[token,above]{A} (t1);    % token A

  \node (not_B) [store, below=of A, label={right:not A}] {} [children are tokens] {[storage] child {node [token] {B}} child {node [token] {C}}} edge [<-] node[token,above]{BC} (t1);   % not token A
\end{tikzpicture}

\end{document}

相关内容