brew install graphviz
vi lz.dot
dot -Tjpg lz3.dot -o lz3.jpg
dot語法
無向圖: - -
有向圖:- >
屬性:節(jié)點和邊顯示樣式(顏色、形狀趟庄、線形)焙畔; 用[key=value,]表示
注釋://單行注釋侧甫; #注釋此行 ; /***/多行注釋
屬性
label=“123” 節(jié)點標簽郭毕,替換節(jié)點默認名稱
shape=box 節(jié)點形狀()
style=filled 樣式 (filled 填充 dashed)
fontcolor=red 字體顏色
color=y(tǒng)ellow 節(jié)點配色
fontname=Courier 字體
penwidth=1.0 線條寬度
//
nodesep=1.0 節(jié)點間距
node [color=Red,] # 所有節(jié)點屬性配置
edge [color=Blue,] # 所有邊屬性配置
圖像屬性
label="My Graph"; # 給圖像設置標簽
rankdir=LR; # 從左到右布局
a->{b c d} # a 分別指向b c d 節(jié)點
{rank=same; a, b, c } # 將一組元素放到同一個level 將abc節(jié)點放置同一水平
splines="line"; # 讓邊框變?yōu)橹本€朋魔,沒有曲線和銳角
K=0.6; # 在布局中影響spring屬性,spring屬性用于將節(jié)點往外推七扰,在twopi和sfdp布局中很有用奢赂。
bgcolor 背景顏色
concentrate = false 讓多條邊有公共部分
nodesep = .25 節(jié)點之間的間隔(英寸)
peripheries = 1 邊界數(shù)
rank (same,min,source, max,sink)設置多個節(jié)點順序
rankdir = TB 排序方向
ranksep = .75 間隔
size 圖的大信惆住(英寸)
譯注:暫時還沒明白這個spring屬性應該怎么翻颈走,初步猜測是彈性。
交點屬性
[label="Some Label"] # 給交點打標簽
[color="red"] # 給交點上色
[fillcolor="blue"] # 設置交點的填充色
shape ellipse 形狀
sides 4 當shape=polygon時的邊數(shù)
fillcolor lightgrey/black 填充顏色
fixedsize false 標簽是否影響節(jié)點的大小
邊的屬性
[label="Some Label"] # 給邊設置標簽 (設置路徑權重的時候很有用)
[color="red"] # 給交點上色 (標示路徑的時候很有用)
[penwidth=2.0] # 給邊適配厚度咱士,標示路徑的時候很有用立由。
arrowhead = normal # 箭頭頭部形狀
arrowsize = 1.0 # 箭頭大小
arrowtail = normal # 箭頭尾部形狀
constraint=true #是否根據(jù)邊來影響節(jié)點的排序
decorate #設置之后會用一條線來連接edge和label
dir=forward # 設置方向:forward,back,both,none
headclip=true # 是否到邊界為止
tailclip=true #與headclip類似
尺寸, 背景顏色
fixedsize=true;
size="1,1";
resolution=72;
bgcolor="#C6CFD532";
eg
digraph structs {
node[shape=record]
struct1 [label="<f0> left|<f1> mid\ dle|<f2> right"];
struct2 [label="{<f0> one|<f1> two\n\n\n}" shape=Mrecord];
struct3 [label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
struct1:f1 -> struct2:f0;
struct1:f0 -> struct3:f1;
}
dot 語言 三種對象:圖表、結點序厉、邊緣
digraph 可控制的
graph 不可控制
subgraph 子圖表
繪制屬性:
形狀:多邊形和紀錄
box盒子 ,
polygon多邊形 ,
ellipse橢圓,
oval橢圓,
circle圓,
point ,
egg卵形,
triangle三角 ,
plaintext ,
diamond菱形 ,
trapezium梯形 ,
parallelogram平行四邊形 ,
house ,
pentagon五角形 ,
hexagon六角形 ,
septagon ,
octagon八邊形 ,
doublecircle ,
doubleoctagon ,
tripleoctagon