开发者

Create top labels for nodes using graphviz (dot)

I need to create a graph representing a extendable hashing structure. So far I have had success with creating graphs in graphviz (using the dot tool)... I am however having trouble making top labels representing the number of bits for each bucket... What I want to do is开发者_开发技巧 something similar to this:

Create top labels for nodes using graphviz (dot)

What I cannot get done are the small 2's and 1's representing bits.. Can anybody explain how I would go around doing this?

My graph so far looks like this:

digraph G {
nodesep = 0.5;
rankdir = LR;
node [shape=record];

node0[label = "<f0>0 | <f1>1"];
node1[label = "0010 | |", toplabel="1"];

subgraph cluster_0 {
    style=filled;
    color=white;
    node [style=filled,color=white];
    node0;
    label = "i = 1";
}

node0:f0->node1;}

Create top labels for nodes using graphviz (dot)


You may consider using HTML-Like labels if you really must do this with graphviz.

I recreated the mentioned example from wikipedia:

rankdir = LR;
node [shape=none];
splines=false;

n1[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
 <TD CELLPADDING="2">2</TD>
 <TD BORDER="0"></TD>
</TR>
<TR><TD COLSPAN="2" PORT="port00"> 00 </TD></TR>
<TR><TD COLSPAN="2" PORT="port01"> 01 </TD></TR>
<TR><TD COLSPAN="2" PORT="port10"> 10 </TD></TR>
<TR><TD COLSPAN="2" PORT="port11"> 11 </TD></TR>
</TABLE>>];

a[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
 <TD CELLPADDING="0" BORDER="0" COLSPAN="2">
  <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" FIXEDSIZE="TRUE" WIDTH="1" ALIGN="LEFT"><TR><TD>1</TD></TR></TABLE>
 </TD>
</TR>
<TR>
 <TD PORT="porta"> A </TD>
 <TD>k2</TD>
</TR>
</TABLE>>];

b[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
 <TD CELLPADDING="2">2</TD>
 <TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
 <TD PORT="portb" COLSPAN="2"> B </TD>
 <TD>k1</TD>
</TR>
</TABLE>>];

c[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
 <TD CELLPADDING="2">2</TD>
 <TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
 <TD PORT="portc" COLSPAN="2"> C </TD>
 <TD>k3</TD>
</TR>
</TABLE>>];

n1:port00 -> a:porta;
n1:port01 -> a:porta;
n1:port10 -> b:portb;
n1:port11 -> c:portc;

As you can see, the code is not pretty... however, the result comes close:

http://graph.gafol.net/evEKgxwgj

Create top labels for nodes using graphviz (dot)

Please note that there is a variation for the top label for demonstration purposes - node a uses a nested table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜