3ヶ月研修の報告書作成の前準備としてGraphvizについて学習。以下のページを参考にしました。
http://homepage3.nifty.com/kaku-chan/graphviz/
以前、正規表現をDFAに変換(id:rahaema:20080707)するRubyスクリプトを書いたのですが、実行結果が見にくいので、DOT言語で書いてみました。もっとハッシュテーブルっぽく書きたかったのですが…。具体的には,
- ハッシュテーブルの中身に「・」があって,そこから矢印が出て欲しかった。
- ハッシュテーブルの左にインデックスを書きたかった。
です。
図中の「#数字」はDFA状態を、「{数字}」はNFA状態を表しています。
digraph dna_hash { rankdir=LR; node [shape=record,width=.1,height=.1]; node0 [label = "<f0>#0|<f1>#1|<f2>#2|<f3>#3"]; node1 [label = "{{a|\{2,3,4\} |#1}}"]; node2 [label = "{{b|\{2,4,5\} |#3}}"]; node3 [label = "{{a|\{1,2,4,5\}|#2}}"]; node4 [label = "{{b|\{2,4,5\} |#3}}"]; node5 [label = "{{a|\{1,2,4,5\}|#2}}"]; node6 [label = "{{b|\{2,4,5\} |#3}}"]; node7 [label = "{{a|\{1,2,4,5\}|#2}}"]; node0:f0 -> node1; node0:f1 -> node2; node2 -> node3; node0:f2 -> node4; node4 -> node5; node0:f3 -> node6; node6 -> node7; }