Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to draw an image illustriting peer-to-peer communications in Tikz. I have previously drawn flowcharts with relative ease based on the Simple Flowchart Example.

Here is the image that I would like to recreate in Tikz:

enter image description here

My difficulties are:

1. I had to replace the Stickmans with clouds from flowcharts. (Not a big issue, I can live with this)

2. If I want to draw 2 arrow (edge) between client A and B, the result will be a two-way path (one line, with arrowheads on both ends) instead of two seperate arrows. I really want to keep two seperate arrows.

Any help is appreciated.

share|improve this question
1  
Welcome to TeX.SE. A -> produces an arrow at the terminal end of the line, a <- produces an arrow at the start of the line, and a <-> will produce an arrow on both ends. But, it really would be helpful if you provided a MWE including \documentclass and the appropriate packages that sets up the problem. –  Peter Grill Apr 1 at 1:21

2 Answers 2

Something to start with:

\documentclass[border=2mm]{standalone}
\usepackage{lmodern}
\usepackage{tikz}

\usetikzlibrary{shapes.misc,shapes.geometric,shapes.symbols,positioning,shadings}
\begin{document}
\begin{tikzpicture}[font=\sffamily\footnotesize,
    Kliens/.style={cloud, 
        cloud puffs=11, 
        cloud ignores aspect, 
        cloud puff arc=120,
        draw, 
        minimum width=35mm, 
        minimum height=20mm, 
        draw=blue!50, 
             top color= white, 
           bottom color= blue!15,
        align=center},
]

\node[Kliens] (K1) at (0,0) {Kliens A};
\node[Kliens, above right=2cm and 2cm of K1] (K2) {Kliens B};
\node[Kliens, below right=2cm and 2cm of K1] (K3) {Kliens C};

\draw[->] (K1.puff 1) -- (K2.puff 4) node[midway,above,sloped]{A input};
\draw[<-] (K1.puff 11) -- (K2.puff 5) node[midway,above,sloped]{B input};

\draw[->] (K1.puff 6) -- (K3.puff 4) node[midway,above,sloped]{A input};
\draw[<-] (K1.puff 7) -- (K3.puff 3) node[midway,above,sloped]{C input};

\draw[->] (K2.puff 6) -- (K3.puff 2) node[midway,above,sloped]{B input};
\draw[<-] (K2.puff 7) -- (K3.puff 1) node[midway,above,sloped]{C input};
\end{tikzpicture}
\end{document} 

enter image description here

share|improve this answer
    
Although I did not use this solution, +1 for node[midway,above,sloped]. It was useful –  VSZM Apr 5 at 10:49
up vote 0 down vote accepted

My main problem was, that if I want tikz to draw 2 lines between nodes A and B, tikz will always draw the shortest connecting line between the nodes, hence the lines will overlap. At the end of the day I was too lazy to draw a stickman.

I had to define the connecting angles between the nodes.

My final solution:

\begin{figure}[!htb]
\centering
\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [cloud, fill=red] (KliensA) {\textit{A} Kliens};
    \node [cloud, fill=green, right=5cm of KliensA] (KliensB) {\textit{B} Kliens};
    \node [cloud, fill=orange, below=5cm of KliensA] (KliensC) {\textit{C} Kliens};
    \node [cloud, fill=purple, below=5cm of KliensB] (KliensD) {\textit{D} Kliens};

    % Draw edges
    \path [line,red] (KliensA.60) --  node {A input} (KliensB.120);
    \path [line,red] (KliensA.210) --  node[midway,above,sloped]{A input} (KliensC.150);
    \path [line,red] (KliensA.0) --  node {A input} (KliensD.90);
    \path [line,green] (KliensB) --  node {B input} (KliensA);
    \path [line,green] (KliensB.270) --  node {B input} (KliensC.0);
    \path [line,green] (KliensB) --  node[midway,below,sloped] {B input} (KliensD);
    \path [line,orange] (KliensC) --  node[midway,below,sloped] {C input} (KliensA);
    \path [line,orange] (KliensC.90) --  node {C input} (KliensB.180);
    \path [line,orange] (KliensC) --  node {C input} (KliensD);
    \path [line,purple] (KliensD.180) --  node {D input} (KliensA.270);
    \path [line,purple] (KliensD.30) --  node[midway,above,sloped] {D input} (KliensB.330);
    \path [line,purple] (KliensD.240) --  node {D input} (KliensC.300);
\end{tikzpicture}
\caption {Kommunikáció peer-to-peer modell esetén.}
\label{Peer2PeerFigure}
\end{figure}

Output:

enter image description here

share|improve this answer
1  
tikz-uml has an actor style for the stickman –  percusse Apr 5 at 14:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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