[Tex/LaTex] TikZ edge between multiple source nodes and single target node

tikz-pgf

I'm trying to achieve something like the following:

Sample image

(Please ignore the node styles, I've sorted that part, it's the edges I'm struggling with!)

My diagrams can have undirected edges that join arbitrary sets of nodes together; I use small perpendicular marks to distinguish different edges. So for example, the rightmost edge above is a single edge with two source nodes and a single target, and the two edges to its left are distinct.

My questions are:

  1. How can I easily add the perpendicular marks (I'd ideally like to say "add a small mark after 70% of the edge")?

  2. How do I specify an edge with multiple source nodes (or multiple target nodes)? I suppose I'd like to specify a point "someway" between the connection points as the "convergence" point of the edges.

I realise number 2 is quite vague, since I haven't specified precisely what I want, but I hope someone can point me in the right direction!

My (very) poor attempt so far is as follows:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
    \node[draw, circle] (p0)                     {};
    \node[draw, circle] (p1) [right of=p0]       {};
    \node[draw, circle] (p2) [above right of=p1] {};
    \node[draw, circle] (p3) [below right of=p1] {};
    \node[draw, circle] (p4) [below right of=p2] {};
    \draw (p0.east) to (p1.west);
    \draw (p1.east) to (p2.west);
    \draw (p1.east) to (p3.west);
    \draw (p2.east) -- (p3.east) -- (p4.west); % This is just wrong! :-)
\end{tikzpicture}
\end{document}

Thanks!

Best Answer

Remarks

Concerning your questions

  1. You can use the mark inside property on your path, where the first argument is the segment of the path where the mark will be placed, e.g. \draw[mark inside=0.7] (0,0) -- (1,1); will set the mark at 70% of the line.

  2. I introduced an additional node in between the three ones called (helper).

Implementation

\documentclass[tikz]{standalone}
\usetikzlibrary{petri,decorations.markings}
\tikzset{
    >=latex,
    node distance = 2cm,
    every place/.style = {minimum size = 6mm},
    mark inside/.style = {
        postaction = {
            decorate,
            decoration={
                markings,
                mark=at position #1 with {\draw[-] (0,-0.1) -- (0,0.1);}
            }
        }
    }
}
\begin{document}
\begin{tikzpicture}
    % Places
    \node[place,tokens=1] (p0)                                           {};
    \node[coordinate]     (start)  [node distance=0.5cm,left of=p0]      {};
    \node[place,tokens=1] (p1)     [right of=p0]                         {};
    \node[place]          (p2)     [above right of=p1]                   {};
    \node[place]          (p3)     [below right of=p1]                   {};
    \node[coordinate]     (helper) [below right of=p2]                   {};
    \node[place]          (p4)     [node distance=0.7cm,right of=helper] {};
    \node[coordinate]     (end)    [node distance=0.5cm,right of=p4]     {};
    % Connections
    \draw (start)   edge[->]                               (p0.west);
    \draw (p0.east) edge[>->]                              (p1.west);
    \draw (p1.east) edge[>->,mark inside=0.5,out=0,in=180] (p2.west);
    \draw (p1.east) edge[>->,mark inside=0.5,out=0,in=180] (p3.west);
    \draw (p2.east) edge[>-,out=0,in=180]                  (helper);
    \draw (p3.east) edge[>-,out=0,in=180]                  (helper);
    \draw (helper)  edge[mark inside=0,->]                 (p4.west);
    \draw (p4.east) edge[>-]                               (end);
\end{tikzpicture}
\end{document}

Output

enter image description here