GraphVizを使ったぞ。

GraphVizは、dot言語でグラフを記述してpdfやpngとかで出力できる。

GraphViz for discrete math studentsというページでdotのサンプルを確認した。
僕の場合、重み付き有向グラフの描画をできれば良いのでこれだけでよかった。

<雑なdotサンプル>

digraph {
    a -> b[label="0.1",weight="0.1"];
    b -> c[label="0.2",weight="0.2"];
    c -> a[label="0.3",weight="0.3"];
}

weightは、重みをいれたらいいのは分かるが、ラベルとして表示されるわけではなかった。
グラフ描画をいいかんじにしてくれるというくらいの認識。

↓manはこう言ってました。

weight=n where n is the integer cost of the edge. 
         Values greater than 1 tend  to  shorten  the  edge.
Weight 0 flat edges are ignored for ordering nodes.

f:id:niyarin-man:20170204202921p:plain
おしまい。