Skip to content

Instantly share code, notes, and snippets.

@v0y4g3r
Last active May 20, 2018 03:24
Show Gist options
  • Save v0y4g3r/3f80314eb48662abf3a37b045ca50a20 to your computer and use it in GitHub Desktop.
Save v0y4g3r/3f80314eb48662abf3a37b045ca50a20 to your computer and use it in GitHub Desktop.
[hashtable.dot] 使用graphviz画hash table #graphviz

效果:

digraph g{
    rankdir=LR;
    node [shape=record,width=01,height=.1];

    a[shape=plaintext,label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
        <TR><TD PORT="a" BGCOLOR="gray">Hash Table</TD></TR>
        <TR><TD PORT="b">Node</TD></TR>
        <TR><TD PORT="c">Node</TD></TR>
        <TR><TD PORT="d">TreeNode</TD></TR>
        </TABLE>>]; //锚点使用PORT属性确定


    {
        // graph[rankdir=LR]    
        node1[label="{<1>A1|<2>A2|...|An}"]
        node2[label="{<1>B1|<2>B2|...|Bn}"]
        // node3[label="{<1>C1|<2>C2}"]
        subgraph cluster_treenode{
            penwidth=0;
            node[shape=circle];
            root[label="", style=filled,fillcolor=black,width=.2];
            n1[label="", style=filled,fillcolor=red,width=.2]
            n2[label="", style=filled,fillcolor=black,width=.2]
            n3[label="", style=filled,fillcolor=black,width=.2]
            n4[label="", style=filled,fillcolor=red,width=.2]
            n5[label="", style=filled,fillcolor=black,width=.2]
            n6[label="", style=filled,fillcolor=black,width=.2]
            root->n1;
            n1->n2;
            n1->n3;
            root->n4;
            n4->n5;
            n4->n6;
        }
    }
    
    a:b:e->node1:1 [style=dashed];
    a:c:e->node2:1;    
    a:d:e->root;    

    // node3:d->node3:sa2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment