tikz petri 网之间的直角边

tikz petri 网之间的直角边

这个问题包含有关如何使用draw和使连接各个节点的边以直角转弯的详细信息edge。但是,我正在使用petriTikz 库,因此边是自动绘制的。我如何指示 Tikz 以直角转弯绘制这些边?

编辑:代码如下:

\begin{tikzpicture}[node distance=1.5cm,,xscale=2,>=stealth',bend angle=45,auto]
    \tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=3mm]
    \tikzstyle{red place}=[place,draw=red!75,fill=red!20]
    \tikzstyle{transition}=[rectangle,thick,draw=brown!75,
          fill=brown!20,minimum size=3mm]
    \tikzstyle{every label}=[blue!75]

    \begin{scope}
        \path
            (0, 0) node [place,tokens=1,label=above:\s{$i$}] (pi) {}
            ++(-1, -1) node [place] (p1) [label=above:\s{$p1$}] {}
            ++(1, -1) node [place] (p2) [label=left:\s{$p2$}] {}
            +(-1, -1) node [place] (p3) [label=left:\s{$p3$}] {}
            ++(1, -1) node [place] (p4) [label=right:\s{$p4$}] {}
            +(1, 0) node [place] (p6) [label=left:\s{$p6$}] {}
            ++(-1, -1) node [place] (p5) [label=left:\s{$p5$}] {}
            ++(0, -2) node [place] (po) [label=above:\s{$o$}] {}

            ++(0, 5) node [transition] (t1) {\s{fork}}
            edge [pre] (pi)
            edge [post] (p1)
            edge[post,-|] [post] (p6)
            edge [post] (p2)
            ++(-1, -1) node [transition] (t2) {\s{check\_insurance}}
            edge [pre] (p1)
            edge [post] (p3)
            +(2, 0) node [transition] (t3){\s{contact\_garage}}
            edge [pre] (p2)
            edge [post] (p4)
            ++(1, -1) node [transition] (t4) {\s{join}}
            edge [pre] (p3)
            edge [pre] (p4)
            edge [post] (p5)
            +(3, 0) node [transition] (t5) {\s{inform\_customer}}
            edge [pre and post] (p6)
            ++(-1, -2) node [transition] (t6) {\s{pay\_damage}}
            edge [pre] (p5)
            edge [pre] (p6)
            edge [post] (po)
            +(2, 0) node [transition] (t7)  {\s{send\_letter}}
            edge [pre] (p5)
            edge [pre] (p6)
            edge [post] (po);
    \end{scope}
\end{tikzpicture}

答案1

从手册中获取示例并应用其中提到的解决方案回答

\tikzset{
    -|/.style={to path={-| (\tikztotarget)}},
    |-/.style={to path={|- (\tikztotarget)}},
}

在此处输入图片描述

\documentclass[margin=6]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning,petri}

\tikzset{
    -|/.style={to path={-| (\tikztotarget)}},
    |-/.style={to path={|- (\tikztotarget)}},
}

\begin{document}
\begin{tikzpicture} \node[place,tokens=2,label=above:$p_1$] (p1) {}; \node[place,label=above:$p_2\ge1$,right=of p1] (p2) {};
\node[transition,below right=of p1,label=below:$t_1$] {} edge[pre,-|] (p1)
edge[post,-|] node[auto] {2} (p2);
\end{tikzpicture}
\end{document}

相关内容