How to create an edge style in tikz with a crossing in the middle and a label near it?

I wonder how to recreate an edge between nodes in Petri Nets using tikz that would look like this:

I played with different options yet cant get it wright.

A minimal code sample I am trying to integrate it into would look like this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,shapes,automata,petri,positioning}
\tikzset{
place/.style={
circle,
thick,
draw=black!75,
%fill=white!20,
minimum size=6mm,
},
transitionV/.style={
rectangle,
thick,
fill=black,
minimum height=8mm,
inner xsep=2pt
}
}

\begin{document}

\begin{tikzpicture}[node distance=0.4cm and 1cm,>=stealth',bend angle=45,auto]
\node [transitionV,label=above:$T_1$] (t1) {};
\node [place,tokens=1,label=above:$P_2$] (p2) [right=of t1] {}
edge[pre]   (t1);

\end{tikzpicture}

\end{document}


Which produces an image like this:

Yet I can not get how to create an edge style in tikz with a crossing in the middle and a label near it alike one on the first figure (selected in red)?

Define a decoration style like

    markedge/.style={
decoration={ markings,
mark=at position .5 with {\draw[-,thick] (-2mm,2mm) -- (2mm,-2mm)node[inner sep=1pt,pos=0.5,auto]{#1};}  %% adjust 2mm etc as you wish
},
postaction={decorate}
},


and then use it like

....edge[pre,markedge={2}]   (t1);


This needs \usetikzlibrary{decorations.markings}.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,shapes,automata,petri,positioning,decorations.markings}
\tikzset{
place/.style={
circle,
thick,
draw=black!75,
%fill=white!20,
minimum size=6mm,
},
transitionV/.style={
rectangle,
thick,
fill=black,
minimum height=8mm,
inner xsep=2pt
},
markedge/.style={
decoration={ markings,
mark=at position .5 with {\draw[-,thick] (-2mm,2mm) -- (2mm,-2mm)node[inner sep=1pt,pos=0.5,auto]{#1};}  %% adjust 2mm etc as you wish
},
postaction={decorate}
},
}

\begin{document}

\begin{tikzpicture}[node distance=0.4cm and 1cm,>=stealth',bend angle=45,auto]
\node [transitionV,label=above:$T_1$] (t1) {};
\node [place,tokens=1,label=above:$P_2$] (p2) [right=of t1] {}
edge[pre,markedge={2}]   (t1);

\end{tikzpicture}

\end{document}


• How to add a label to it? Jan 15, 2015 at 14:42
• @DuckQueen Sorry, I missed that part. See the edit.
– user11232
Jan 16, 2015 at 0:23