0

I have found some similar solutions by tikz. Here is the link.

https://github.com/MartinThoma/LaTeX-examples/blob/master/tikz/resource-allocation-graph/resource-allocation-graph.tex

https://github.com/MartinThoma/LaTeX-examples/tree/master/tikz/resource-allocation-graph

But the graph in the book which has some variations.

It have some dots in the rectangles and some lines are from the dots not from rectangles.

So if there is some solution based on that one to meet the requirements, it is nice. Thanks.

RAG

2

Not sure if I'm really answering your question, but here you go. The shading on the circles isn't quite right, but I think the rest is pretty close.

enter image description here

Code:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{xcolor}

\definecolor{sqBlue}{RGB}{218,234,233}
\definecolor{ballBlue}{RGB}{40,156,156}

\begin{document}
\begin{tikzpicture}[x=0.6in,y=0.6in]

%% Draw the rectangles
\draw[fill = sqBlue] (-0.5,0) rectangle (0.5,1);
\node at (0,0.75) {Ra};
\draw[fill = sqBlue] (-0.5,-3.5) rectangle (0.5,-2.5);
\node at (0,-3.25) {Rb};

%% Draw the big circles
\fill[ball color = ballBlue] (1.6875,-1.25) circle[radius=0.5] node {P2};
\fill[ball color = ballBlue] (-1.6875,-1.25) circle[radius=0.5] node {P1};

%% Draw the small dots
\coordinate (a) at (-0.344,0.19);
\coordinate (b) at (-0.0625,0.19);
\coordinate (c) at (0.25,0.19);
\coordinate (d) at (-0.0625,-2.69);
\coordinate (e) at (0.22,-2.69);

\draw[fill = black] (a) circle[radius=0.075];
\draw[fill = black] (b) circle[radius=0.075];
\draw[fill = black] (c) circle[radius=0.075];
\draw[fill = black] (d) circle[radius=0.075];
\draw[fill = black] (e) circle[radius=0.075];

%% Draw the arrows
\draw[-latex', very thick] (b) to node[sloped, above, inner sep = 2pt] {\footnotesize\hspace{1em}Held by} (1.37,-0.88);
\draw[latex'-, very thick] (0.375,-2.5) to node[sloped, above, inner sep = 2pt] {\footnotesize Requests} (1.37,-1.63);
\draw[-latex', very thick] (d) to node[sloped, above, inner sep = 2pt] {\footnotesize Held by} (-1.37,-1.63);
\draw[-latex', very thick] (-1.37,-0.88) to node[sloped, above, inner sep = 2pt] {\footnotesize\hspace{-2em}Requests} (-0.19,0);

\end{tikzpicture}
\end{document}
  • It couldn't be compiled successfully. Here is the error message: "l.37 \draw[latex'-, very thick] (0.375,-2.5) to node[sloped, above, inner se..." – Christophe Mar 9 '16 at 2:27
  • @Christophe Can you share the entire log file? The snippet you gave is not enough to diagnose the issue. – Tony Mottaz Mar 9 '16 at 2:29
  • paste.ubuntu.com/15332111 – Christophe Mar 9 '16 at 2:33
  • Ah! I somehow lost a square bracket when copying my code. My answer has been updated, and it should work now. – Tony Mottaz Mar 9 '16 at 2:37
  • Thanks a lot! I use your example to make my own graph successfully. – Christophe Mar 9 '16 at 3:49

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.