AT&Tのオープンソースでグラフ構造を描画するツール。~
dot言語を用いて記述する。~
Doxygenなんかで関数呼び出しやクラスの関連図の可視化にも使われているようだ。
***簡単な使い方 [#e7ee2471]
A→B, B→C, C→Aの辺を持つ有向グラフの描画~
test.dot
 digraph "g" {
    "A" -> "B" ;
    "B" -> "C" ;
    "C" -> "A" ;
 }
で、test.dotをdottyかlneatoに食わせると新しいウィンドウで描画する。~
ファイルに書き出すときは、
 dot -Kneato -Tgif test.dot -o test.gif
引数の-Kはレイアウトエンジンでcirco, dot, fdp, neato, twopiの5つのどれか。-Tは出力ファイルのフォーマットでdot, gif, jpg, png, ps, svgとか色々ある。
#ref(http://reddog.s35.xrea.com/img/graphviz-test.gif,nolink,left)

***dottyの使い方 [#ifb61a16]
dottyは対話的にノードや辺を追加してグラフを描画するツール。~
-左クリックでノードの追加
-ホイール長押し+ドラッグで辺の追加
-右クリックで色々メニューが出る。attrで属性の変更。

レイアウトの仕方が違うdottyとlneatoがある。実はleftyを実行するラッパーなので、次のようにleftyをコマンドラインから呼び出しても同じ。上がdottyで下がlneato。
 lefty -e load('dotty.lefty');dotty.simple(null);
 lefty -e load('dotty.lefty');dotty.protogt.lserver='neato';dotty.simple(null);

dottyはPEAT図とか有向グラフで、lneatoは無向グラフで使うのがいいと思う。
***属性 [#kad57457]
よく使いそうなのをピックアップ。マニュアルにもっと載ってる。~
-ノードの属性
,label       ,ラベル
,color       ,色
,fillcolor   ,背景色
,fontcolor   ,文字色
,fontsize    ,フォントサイズ
,fontname    ,font family
,shape       ,ellipse circle doublecircle polygon box point diamond
,regular     ,shape=polygon時に正n角形にする。(true/false)
,sides       ,shape=polygon時の辺の数
,distortion  ,shape=polygon時に台形にする(0.0~)
,skew        ,shape=polygon時に斜めにする(0.0~)
,orientation ,ノードの回転
,style   ,bold dotted filled
-エッジの属性
,arrowhead      ,辺の開始点の矢印のスタイル normal none
,arrowtail      ,辺の終了点の矢印のスタイル normal none
,arrowsize      ,矢印のサイズ
,color          ,矢印の色
,dir            ,forward back both none
,fontcolor      ,フォントの色
,fontname       ,font family
,fontsize       ,フォントサイズ
,headlabel      ,head側に置くラベル
,taillabel      ,tail側に置くラベル
,label          ,ラベル
,labelfontcolor ,ラベルの色
,style          ,bold dotted filled
,constraint     ,辺をノードのランキングの計算で使うかどうか(true/false)
,minlen         ,辺の最小の長さ デフォルトで1
,weight         ,辺の重み付け デフォルトで1。二つの枝の重いほうが真横(真下)に来る。
-グラフの属性
,bgcolor      ,背景色
,color        ,アウトラインなどの色
,fillcolor    ,塗りつぶし色
,fontcolor    ,文字色
,fontname     ,フォント
,fontsize     ,フォントサイズ
,fontpath     ,フォントを探すパス
,rankdir      ,LR(left-right)か、TB(top-bottom)
,ranksep      ,ノード間の距離。デフォは0.75
,splines      ,スプラインで描画(true/false)
,overlap      ,重ねて描画(true/false)
,orientation  ,portrait/landscape
,ratio        ,fill/auto/compress

***日本語 [#r73d2ece]
Windows版のdottyで日本語を表示することはできない(ようだ)が、dotから出力する画像ファイルで日本語を出力することは可能。バージョンはGraphviz2.6。以下そのやりかた。~
+dotファイルをUTF-8で書く。fontnameにTTFのファイル名を書く。Windows2000の場合、C:\WINNT\FONTにパスが通ってるので、適当に見繕ってARIALUNI.TTFを使って見る。~
 graph "g" {
    node [shape=circle, fontname="arialuni.ttf", fontsize=10, 
        width=0.5, margin=0.0]
    edge [minlen=5]
    "五代" -- "響子" -- "一ノ瀬" -- "五代";
    "三鷹" -- "響子";
    "一ノ瀬" -- "三鷹";
    "音無家" -- "響子"
    "明日菜" -- "三鷹";
    "九条家" -- "明日菜";
    "三鷹家" -- "三鷹";
    "九条家" -- "三鷹家";
    "こずえ" -- "五代";
    "八神" -- "五代";
 }
+普通に出力
 dot -Kneato -Tgif test.dot -o jpfont.gif
#ref(jpfont.gif,nolink,left)

***日本語その2 [#g5a1862a]
#ref(dotty.gif,nolink,left)
leftyの改造によるdottyの日本語入力。

//leftyの日本語化(未完成)
//+graphviz-win-2.6/graphviz-win/cmd/lefty/ws/mswin32/lefty.rcでfontを決め打ちしてる個所を削除。
//+graphviz-win-2.6/graphviz-win/cmd/lefty/ws/mswin32/gcanvas.cとgpcanvas.cの//CreateFont()の部分をちゃんと書く。
//+dotty.leftyで日本語フォントをデフォルトにするよう変更する。
//このままではshiftjis特有の文字化けを解消することができないので、内部コードをUFT-8化するか、エスケープする処理を加えるかしなければならない。UTF-8化する場合、組み込みのパーサーの書き換えやソースコードの文字コードの変更をしなければならない可能性もあるのでめんどくさそう。描画直前にUnicodeに変換してDrawTextWで描画する方法もあるけどうーむ。
まだ改造途中でshiftjis特有の文字化けが残っている。たとえば、表示が侮ヲになったりするので、「set label=日本語\\\表示」みたいに特定の文字をエスケープしてやらないといけない。あとファイルの入出力もshiftjisで、dottyに直接食わせることができるのがutf-8なので、この辺もutf-8に統一したほうがよい。内部コードをutf-8に統一するのが一番近道のような気がするが・・・めんどくさそうだったのでとりあえず放置して様子見中。
-パッチ~
http://reddog.s35.xrea.com/software/graphviz-win-jp.patch
-バイナリ(置き換えてください)~
http://reddog.s35.xrea.com/software/lefty-jp.zip

***dot言語メモ [#af2d6cfc]
-ノードのランクを同じにする
 digraph g {
     1 -> 2 -> 3;
     {rank=same; 1 A B C;}
     {rank=same; 2 D E F;}
     {rank=same; 3 G H I;}
 }
-ノードのクラスタ化
 digraph g {
     subgraph cluster1 {
         label=cluster1;
         A B C;
     }
     subgraph cluster2 {
         label=cluster2;
         D E F;
     }
     A -> E -> D
     A -> C -> F
 }
-ちょっと便利な書き方
 n0 -> n1
 n0 -> n2
 n0 -> n3
というのは
 n0 -> {n1 n2 n3};
というふうにまとめて書ける。

***Tcl関連 [#ha63f75b]
-[[Package ASDOT:http://wiki.tcl.tk/3717]]~
Tcllibのstruct::graphとdot形式の相互変換。struct::graphのバージョンアップで挙動不審になってる気がする。簡単なdotを読み込めん。簡単な出力はできるようだ。

***コメントをどーぞ [#uf3b3ae9]
-dottyの使いかたで「右クリックでノードの追加」とありますが、当方の環境では 左クリックでした。 --  &new{2005-09-23 19:41:05 (金)};
-すいません間違えていました。ご指摘ありがとうございます。 -- [[reddog]] &new{2005-09-23 21:58:52 (金)};
-"惣一郎"ノードも欲しいですね ;-) --  &new{2005-10-06 21:14:04 (木)};
-dottyの日本語入力するための方法を教えていただけるとありがたいです -- [[とおりすがり]] &new{2005-11-01 20:30:53 (火)};
-allowhead,allowtail,allowsizeはarrowhead,arrowtail,arrowsizeの間違いでは? -- [[none]] &new{2005-11-10 17:40:25 (木)};
-直しました。すいません。 -- [[reddog]] &new{2005-11-10 18:02:13 (木)};
-画像の直リンクは迷惑なのでしないでください。 -- [[reddog]] &new{2006-02-24 23:12:31 (金)};
- AZpUgQ http://www.HyAkX1fLLA7FJn7pQJypwjpWJBQWQggb.com -- [[Wilman]] &new{2012-09-09 (Sun) 08:59:05};
- A jiffy bag http://www.sedrez.com topamax normal dosage   Ophthalmic and otic preparations  -- [[Tyler]] &new{2012-09-26 (Wed) 08:06:59};
- I can't get a signal http://www.flystanford.com buy retin-a gel  for (431-DV), use to itemize paid amounts or  -- [[Alexa]] &new{2012-10-03 (Wed) 10:14:48};
- perfect design thanks http://www.eccenewmusic.org seroquel cost comparison  gravimetric and volumetric measuring and identifying incompatibilities among  -- [[Zoey]] &new{2012-10-04 (Thu) 02:43:30};
- I have my own business http://blog.ifuller1.info cheap alternative abilify  D. Payment for medications dispensed in quantities in lesser or greater amounts  -- [[Jozef]] &new{2012-10-04 (Thu) 20:48:59};
- How many more years do you have to go? http://www.wpifoundation.org amitriptyline purchase online  The time I spent in Kenya certainly has given me a more accurate frame of  -- [[Jack]] &new{2012-10-05 (Fri) 06:15:47};
- I'm training to be an engineer http://sarahcaluag.com buy trazodone sleep  13.0 PHARMACY UT/P & C CODES - TABLE 8 (Rev. 05/09)  -- [[Isabella]] &new{2012-10-06 (Sat) 07:06:52};
- Your cash is being counted http://meandsarah.com discount paxil cr  questions arise, maintains professional attitude, asks in private and not  -- [[Henry]] &new{2012-10-06 (Sat) 14:31:59};
- What's your number? http://www.pinellasanimalfoundation.org prozac prices without insurance  Denials will come first in the response, then warnings.  -- [[Justin]] &new{2012-10-07 (Sun) 06:54:04};
- International directory enquiries http://www.viddjupid.is cipralex online  0, 1, 3, 5, 6 Zeros 51 Non-ECCA If all other edits are passed, the transaction  -- [[Mia]] &new{2012-10-07 (Sun) 09:04:02};
- How much is a First Class stamp? http://marcianitosverdes.haaan.com zoloft coupon  Information Processed Field 431-DV = Amount Reported on the claim is  -- [[Vida]] &new{2012-10-07 (Sun) 23:19:11};
- I've only just arrived http://serdika.com.ar/ purchase cymbalta canada  Insulin 38, 39 Prior Authorization 7, 42, 43, 44, 54  -- [[greenwood]] &new{2012-10-08 (Mon) 21:54:44};
- Punk not dead  http://ciudadessinviolencia.sitiosur.cl buy desyrel font  may see some more westernized looking outfits worn by both men and women,  -- [[Michelle]] &new{2012-10-09 (Tue) 22:53:42};
- Incorrect PIN http://www.nsmedia.se lexapro over the counter  1.6. Monitor, evaluate patient patients. can verbalize and/or administration, and continuity  -- [[steep777]] &new{2012-10-10 (Wed) 23:53:54};
- We were at school together http://www.intisoft.co.id celexa online pharmacy  yours and which threaten your basic, unconscious belief that you culture’s customs, assumptions,  -- [[Lucky]] &new{2012-10-12 (Fri) 00:46:39};
- Not in at the moment http://www.paulavalenca.org/ duloxetine new zealand  Excerpted from: Chapter 9 - Fraud, Waste and Abuse (v04.25.06) [PDF,  -- [[Mya]] &new{2012-10-13 (Sat) 01:55:46};
- http://fvfgbghnb.com -- [[zoiberg]] &new{2012-10-13 (Sat) 04:53:16};
- I'm sorry, she's  http://akronfilm.com seroquel order  DC The description of the drug/disease contraindication.  -- [[Madelyn]] &new{2012-10-14 (Sun) 02:59:21};
- T5sjHn http://www.PCsrDV86SgUVGcoBbz6moa5pI7jMrOFz.com -- [[horny]] &new{2012-10-16 (Tue) 03:55:55};
- How many more years do you have to go? http://www.summit-ctd.com imitrex price usa  partnerships between universities to foster service, training, and research that benefit  -- [[Barry]] &new{2012-10-16 (Tue) 07:28:58};
- I'm doing an internship http://www.info-kod.ba clomid no prescription  Medicare Coverage (cont) BD = Recipient has both Part B and Part D Medicare  -- [[Lucky]] &new{2012-10-17 (Wed) 10:18:11};
- The National Gallery http://www.arsvivendi.com purchase generic prozac  The following documents represent the assessment tools which must be utilized in order  -- [[Adrian]] &new{2012-10-18 (Thu) 22:55:51};
- Another service? http://www.puschnig.com buy diflucan online  For Clinical Significance 1 the words REJECT± DRUG OVERUSE MMDDYY  -- [[Brianna]] &new{2012-10-20 (Sat) 02:02:20};
- Could I have , please? http://www.joomx.com neurontin issues  age of 65, dependents are generally covered on the provincial plan. This means that TELUS Health Solutions is the second payer  -- [[Jocelyn]] &new{2012-10-21 (Sun) 05:06:16};
- I'm afraid that number's ex-directory http://www.sandcreek.com where to buy propecia in usa  Provider Manual. This document is available at www.emedny.org by clicking: eMedNY 5010/D.0 Transaction  -- [[Valeria]] &new{2012-10-21 (Sun) 15:17:33};
- I'd like to send this letter by  http://www.aracari.com zithromax online prices  You can use the KENYA POST AND COMMUNICATION network dialing 000-1 (for the US), your  -- [[Mariah]] &new{2012-10-22 (Mon) 08:36:14};
- Have you got any ? http://www.khattarwong.com how much does retin-a cost in canada  Gladiolis Servant’s Quarters—Double bed with a separate bath.  -- [[Caroline]] &new{2012-10-22 (Mon) 10:17:49};
- It's a bad line http://www.smcmba.com zoloft online canada  student handbook for additional details).  -- [[Cooper]] &new{2012-10-23 (Tue) 05:15:31};
- Children with disabilities http://www.eminpasha.com duloxetine rxlist  compare it to previous experiences. The sharing of experiences from previous learning  -- [[Ayden]] &new{2012-10-23 (Tue) 11:33:53};

#comment
//#comment
----
[[CategoryTclTk]]

|New|Edit|Diff|History|Attach|Copy|Rename|
HTML convert time: 0.002 sec.