I can use "record" to draw one array like this one:
graph G{
node [shape = record];
node0 [fontsize=13, label ="A[0]|A[1]|A[2]"];
}
But how can I draw something like this one
Especially, how can I add the index number for each cell in the array, like 0,1,2,3,4,5.
Which node shape should I use?
Update at 2016/11/11
Ok, I got it based on the answer from https://stackoverflow.com/a/37986662/5374561
The code is here:
digraph so
{
rankdir=LR;
subgraph cluster0
{
rank = same{ Array notes }
color = white;
Array [ shape = record, label = "{ A | B | C | D }"] ;
notes [ shape = record, color = white, label = "{ 0 | 1 | 2 | 3 }" ];
Array -> notes[ style = invis ];
}
nodesep = .0;
}
But the result is not perfect. Is there any other ways?
Update at 2016/Aug/9
The solution from tequlia2pop (thank you) is close to the original pictures, but the line from "pointers" to "values" should be straight line.
digraph {
node [shape=plaintext, fontcolor=red, fontsize=18];
"Pointers:" -> "Values:" -> "Indices:" [color=white];
node [shape=record, fontcolor=black, fontsize=14, width=4.75, fixedsize=true];
pointers [label="<f0> A | <f1> A+1 | <f2> A+2 | <f3> A+3 | <f4> A+4 | <f5> A+5", color=white];
values [label="<f0> A[0] | <f1> A[1] | <f2> A[2] | <f3> A[3] | <f4> A[4] | <f5> A[5]", color=blue, fillcolor=lightblue, style=filled];
indices [label="0 | 1 | 2 | 3| 4 | 5", color=white];
{ rank=same; "Pointers:"; pointers }
{ rank=same; "Values:"; values }
{ rank=same; "Indices:"; indices }
edge [color=blue];
pointers:f0 -> values:f0;
pointers:f1 -> values:f1;
pointers:f2 -> values:f2;
pointers:f3 -> values:f3;
pointers:f4 -> values:f4;
pointers:f5 -> values:f5;
}
which yields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With