7

I'm experimenting with Petri Nets and I want to add some horizontal space between two arcs starting from the same transition.

My code:

\begin{tikzpicture}
% Styles
[node distance=1.3cm, on grid,>=stealth',bend angle=45,auto,
every place/.style={minimum size=6mm,thick,draw=blue,fill=white},
every transition/.style={thick,draw=black,fill=black,minimum height=1mm,minimum   width=6mm},
red place/.style={place,draw=red,fill=red!20},
every label/.style={red},
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick}]
% Drawing
\node [transition] (T0) [label=right:$T_0$] {};
\node [place] (P0) [below=of T0, label=right:$P_0$] {}
 edge [pre] (T0);
\node [transition] (T1) [below=of P0, label=right:$T_1$] {}
 edge [pre] (P0);
\node [place] (P1) [below=of T1, label=right:$P_1$] {}
 edge [pre] (T1);
\node [transition] (T2) [below=of P1, label=above right:$T_2$] {}
 edge [pre] (P1);
\node [place] (P2) [below left=of T2, label=left:$P_2$] {}
 edge [pre, bend right] (T2);
\node [place] (P4) [below right=of T2, label=above right:$P_4$] {}
 edge [pre, bend left] (T2);
\node [transition] (T3) [below=of P2, label=left:$T_3$] {}
 edge [pre] (P2);
\node [place] (P3) [below=of T3, label=left:$P_3$] {}
 edge [pre] (T3);
\node [transition] (T4) [below=of P4, label=left:$T_4$] {}
 edge [pre] (P4);
\node [transition] (T5) [right=of T4, label=right:$T_5$] {}
 edge [pre, bend right] (P4);
\end{tikzpicture}

Produces this:

arcs starting from transition without horizontal space

But all I want to achieve is this:

what I want to achieve (from a text book on PN)

How to specify the horizontal space between starting arcs in order to achieve the result showing in the second picture?

  • 1
    Can you please complete your code snippet to a full compilable code? That makes it easier for us to help you ... – Mensch Mar 19 '15 at 11:16
2

Using the calc library you can specify ($(T2)!0.5!(T2.west)$) and ($(T2)!0.5!(T2.east)$) (you can play with the 0.5):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{petri,arrows,positioning}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
% Styles
[node distance=1.3cm, bend angle=45,auto,
every place/.style={minimum size=6mm,thick,draw=blue,fill=white},
every transition/.style={thick,draw=black,fill=black,minimum height=1mm,minimum   width=6mm},
red place/.style={place,draw=red,fill=red!20},
every label/.style={red},
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick}]
% Drawing
\node [transition] (T2) [label=above right:$T_2$] {};
\node [place] (P2) [below left=of T2, label=left:$P_2$] {}
 edge [pre, bend right] ($(T2)!0.5!(T2.west)$);
\node [place] (P4) [below right=of T2, label=above right:$P_4$] {}
 edge [pre, bend left] ($(T2)!0.5!(T2.east)$);
\end{tikzpicture}
\end{document}

enter image description here

4

By default a reference to a node (T2) is a reference to its center (T2.center). So, command

\node [place] (P2) [below left=of T2, label=left:$P_2$] {}
 edge [pre, bend right] (T2);

draws a arrow from (P2.center) to (T2.center) which stops at T2 border. You can introduce a distance making reference to an specific anchor for T2 like ([xshift=-1mm]T2.south)

\documentclass[tikz,border=3mm]{standalone}

\usetikzlibrary{petri, positioning, arrows}

\begin{document}
\begin{tikzpicture}
% Styles
[node distance=1.3cm, on grid,>=stealth',bend angle=45,auto,
every place/.style={minimum size=6mm,thick,draw=blue,fill=white},
every transition/.style={thick,draw=black,fill=black,minimum height=1mm,minimum   width=6mm},
red place/.style={place,draw=red,fill=red!20},
every label/.style={red},
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick}]
% Drawing
\node [transition] (T0) [label=right:$T_0$] {};
\node [place] (P0) [below=of T0, label=right:$P_0$] {}
 edge [pre] (T0);
\node [transition] (T1) [below=of P0, label=right:$T_1$] {}
 edge [pre] (P0);
\node [place] (P1) [below=of T1, label=right:$P_1$] {}
 edge [pre] (T1);
\node [transition] (T2) [below=of P1, label=above right:$T_2$] {}
 edge [pre] (P1);
\node [place] (P2) [below left=of T2, label=left:$P_2$] {}
 edge [pre, bend right] ([xshift=-1mm]T2.south);
\node [place] (P4) [below right=of T2, label=above right:$P_4$] {}
 edge [pre, bend left] ([xshift=1mm]T2.south);
\node [transition] (T3) [below=of P2, label=left:$T_3$] {}
 edge [pre] (P2);
\node [place] (P3) [below=of T3, label=left:$P_3$] {}
 edge [pre] (T3);
\node [transition] (T4) [below=of P4, label=left:$T_4$] {}
 edge [pre] (P4);
\node [transition] (T5) [right=of T4, label=right:$T_5$] {}
 edge [pre, bend right] (P4);
\end{tikzpicture}
\end{document}

enter image description here

4

The quickest fixes are

\node [place] (P2) [below left=of T2, label=left:$P_2$] {} 
     edge [pre, bend right] ([xshift=-1mm]T2.south);
\node [place] (P4) [below right=of T2, label=above right:$P_4$] {} 
     edge [pre,bend left] ([xshift=1mm]T2.south);

that modify the target point or you can give angle input to the bend left/right keys for example with 40 to both you have

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.