(a (b . c) d) という内容のコンスセルを描画してみます。
// (a . ((b . c) . (d . nil)))
// (a (b . c) d)
digraph {
graph [rankdir = LR]; // 横向き
// ノードの定義。
// record型にするとlabelをバー(|)で区分けできる。
// {}で囲うと並べる向きを変えられる。
// 先頭を<xxx>とすると要素への接続ポート名を定義できる。
cons1 [shape = record, label = "{a|*}"];
cons2 [shape = record, label = "{*|*}"];
cons3 [shape = record, label = "{b|c}"];
cons4 [shape = record, label = "{d|nil}"];
// コロン区切りで接続ポートを指定することで、
// エッジの指す先が要素の位置になる。
cons1:cdr -> cons2:car;
cons2:car -> cons3:car;
cons2:cdr -> cons4:car;
// ノードcons2とcons3を同じランク(並ぶ位置)にする
{rank = same; cons2; cons3};
}
ファイル"cell.dot"に保存して、以下のコマンドで画像ファイルを作成できます。
> dot -Tpng cell.dot > cell.png作成される画像は以下。

0 件のコメント:
コメントを投稿