I'm trying to draw the following image using tikz.


Is there an easy way to do this? Thanks

  • 2
    Welcome! What have you tried? You are more likely to get effective help if you post code for a small document people can start from. Can you at least draw the inside node? Note that if you really want a U-shaped node, that is hard. If you just want something which looks like that, it is easy - just lines. – cfr Mar 19 '17 at 19:39

As crf said, you probably do not want to use a node shape for the U, this would be quite complex. What you can do, however, is to exploit nodes to get the shape correct:



            workerWidth/.style={minimum width=3cm},
            workerHeight/.style={minimum height=2cm},
            UWidth/.style={minimum width=1cm},
            every node/.style={
                text centered,
        \node[workerWidth, workerHeight, draw] (worker) at (0, 0) {Worker};

        \node[anchor=north, workerWidth, yshift=-0.5cm] (cache) at (worker.south) {Cache};

        \node[anchor=east, workerHeight, UWidth, xshift=-1cm] (left) at (worker.west) {};
        \node[anchor=west, workerHeight, UWidth, xshift=1cm] (right) at (worker.east) {};

        \draw (left.north west) -- (left.west |- cache.south) -- (right.east |- cache.south) -- (right.north east) -- (right.north west) -- (right.west |- cache.north) -- (left.east |- cache.north) -- (left.north east) -- cycle;

        \draw[<-, >={Latex}] (left.west) -- ++(-1, 0);
        \draw[->, >={Latex}] (left.east) -- (worker.west);
        \draw[->, >={Latex}] (worker.east) -- (right.west);
        \draw[->, >={Latex}] (right.east) -- ++(1, 0);

The result is quite like your image: enter image description here

To get a better idea how it works, I coloured the helping nodes: enter image description here

From these three nodes it uses their base anchors to construct the U shape, while styles ensure, that all nodes are of the correct size (you could do this manually for every node, but this way is ensures consistency).

If you nevertheless really want a U-shaped node, you will probably have to provide more information and give some starting code. That stuff is quite complex.

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.