一、背景描述
最近在研究didi的booster框架,應用到項目中,然後通過執行 assemble task 來構建一個優化過的應用包,構建完成後,在 build/reports/ 目錄下會生成相應的報告。
生成的報告文件中,包含了部分dot文件,如下所示
打開該x.dot文件,是一堆如下面的文本,看不懂
digraph "com.amap.api.col.sl3.x" {
graph [bgcolor="transparent",pad="0.555"];
node [color="#00BFC4",fillcolor="#00BFC440",fontcolor="#333333",fontname=Helvetica,shape=box,style=filled];
edge [fontname=Helvetica];
rankdir = TB;
"x" [color="#CCCC66",fillcolor="#CCCC6640"];
"x:finalize()" [color="#000033",fillcolor="#00003340"];
"x:setRenderer(GLSurfaceView$Renderer)" [color="#993399",fillcolor="#99339940"];
"x$i:start()" [color="#66CC33",fillcolor="#66CC3340"];
"x" -> "x:finalize()" [color="#0033FF",fontcolor="#0033FF"];
"x" -> "x:setRenderer(GLSurfaceView$Renderer)" [color="#9999FF",fontcolor="#9999FF"];
"x:setRenderer(GLSurfaceView$Renderer)" -> "x$i:start()" [color="#669933",fontcolor="#669933"];
}
因此,我們得先了解下什麼是dot文件,什麼是DOT語言?
二、什麼是DOT語言?
-
The DOT Language :https://www.cnblogs.com/itzxy/p/7860073.html
-
在 org-mode 中使用 Graphviz 畫關係圖 https://coldnew.github.io/787b7d73/
下面我們就將上面的博客摘錄過來。摘錄地址:dot language 學習筆記:https://www.cnblogs.com/billnote/p/4043267.html
2.1 dot 語言簡介
DOT語言是一種文本圖形描述語言。文件擴展名通常爲.gv或.dot 。它可以導出的格式有:GIF、PNG、SVG、PDF及PostScript。
2.2 基本語法
2.1 常用圖形
- box、polygon、ellipse、circle、point、triangle、invtriangle、plaintext、diamond
digraph shapes {
"Box"[shape=box]
"Polygon"[shape=polygon,sides=7] /* 定義了一個7邊行,sides屬性定義多邊形邊的數量 */
"Ellipse"[shape=ellipse]
"Circle"[shape=circle]
"Point"[shape=point]
"triangle"[shape=triangle]
"invtriangle"[shape=invtriangle]
"plaintext"[shape=plaintext]
"diamond"[shape=diamond]
}
2.2 常用線條
- 無向線條、又向線條、雙向線條
digraph lines {
"Undirected1"->"Undirected2"[arrowhead=none]
"Undirected1"->"Directed1"
"Directed1"->"Directed2"[dir=both]
}
- 實線、虛線、點線、加粗、透明
digraph lines2 {
rankdir=LR
"solid"->"dashed"[style=solid]
"dashed"->"dotted"[style=dashed]
"dotted"->"bold"[style=dotted]
"bold"->"invis"[style=bold]
"invis"->"solid"[style=invis]
}
2.3 常用箭頭
- box、crow、curve、icurve、diamond、dot、inv、none、normal、tee、vee
digraph arrow {
rankdir=LR
"box"->"crow"[arrowhead=box]
"crow"->"curve"[arrowhead=crow]
"curve"->"diamond"[arrowhead=curve]
"diamond"->"dot"[arrowhead=diamond]
"dot"->"inv"[arrowhead=dot]
"inv"->"none"[arrowhead=inv]
"none"->"normal"[arrowhead=none]
"normal"->"tee"[arrowhead=normal]
"tee"->"vee"[arrowhead=tee]
"vee"->"box"[arrowhead=vee]
#來個高級的用法
a->b[arrowhead=lcrowortee]
}
2.4 常用屬性
2.4.1 Node常用屬性
屬性名 | 默認值 | 說明 |
---|---|---|
color | black | node圖形顏色,see color values |
fontcolor | black | 字體顏色 |
fontname | Times-Roman | 字體 |
fontsize | 14 | 字體大小 |
image | node背景圖片地址 | |
label | node name | node 顯示內容 |
shape | ellipse | 形狀 |
style | 圖形樣式,eg. bold、dotted、filled | |
height | .5 | 最低高度尺寸 |
width | .75 | 最低寬度尺寸 |
URL | 點擊跳轉地址 | |
target | 點擊跳轉打開方式 |
digraph demo_node {
rankdir=LR
"default_node"
"node"[shape=box,color=antiquewhite,style=filled,label="node attrs",fontcolor=brown,fontsize=10,URL="http://www.baidu.com",target="_brank"]
"default_node"->"node"
}
2.4.2 Edge常用屬性
屬性名 | 默認值 | 說明 |
---|---|---|
arrowhead | normal | 箭頭樣式 |
arrowsize | 1.0 | 箭頭尺寸 |
color | black | 顏色 |
dir | forward | 箭頭方向 |
edgeURL | 點擊跳轉地址 | |
fontcolor | black | 字體顏色 |
fontname | Times-Roman | 字體 |
fontsize | 14 | 字體大小 |
headport | 線條頭部連接處,eg.n、ne、e、se、s、sw、w、nw | |
label | 描述內容 | |
labelfontcolor | black | label字體顏色 |
labelfontname | Times-Roman | label字體 |
labelfontsize | 14 | label字體大小 |
style | 圖形樣式,eg.bold、dotted、filled | |
tailport | 線條尾部連接處,eg.n、ne、e、se、s、sw、w、nw | |
weight | 1 | integer cost of stretching an edge |
digraph demo_edge {
rankdir=LR
a->b[label="Yes",labelfontcolor=blue]
edge[arrowhead=box,arrowsize=1.5,color=red,dir=both,style=dotted,weight=10]
b->c
}
2.4.3 Graph常用屬性
屬性名 | 默認值 | 說明 |
---|---|---|
bgcolor | 背景顏色 | |
color | black | for clusters,outline color,and fill color |
dpi | 96 | 圖像輸出像素 |
fillcolor | black | cluster fill color |
fontcolor | black | 字體顏色 |
fontname | Times-Roman | 字體 |
fontsize | 14 | 字體大小 |
label | 描述內容 | |
landscape | true:orientation=landscape | |
rank | 子圖等級限制, same,min,max,source,sink | |
rankdir | TB | 圖片排列方式,LR(left to right) or TB(top to bottom) |
size | 最大圖片尺寸 | |
style | 圖片樣式 | |
stylesheet | pathname or URL to XML style sheet for SVG | |
URL | 點擊跳轉地址 | |
target | 點擊跳轉打開方式 |
digraph demo_graph {
bgcolor=beige
fontcolor=gray10
fontsize=12
label="this is demo"
rankdir=TB
{rank=same; "level1" "a-level1" "b-level1" "c-level1"}
{rank=same; "level2" "d-level2" "e-level2"}
{rank=same; "level3" "f-level3" "g-level3" "h-level3" "i-level3" "j-level3"}
{rank=same; "level4" "k-level4"}
"level1"->"level2"->"level3"->"level4"
"a-level1"->"d-level2"
"e-level2"->{"h-level3", "k-level4"}
"b-level1"->{"e-level2", "f-level3", "i-level3", "k-level4"}
"c-level1"->{"d-level2", "g-level3", "h-level3"}
"j-level3"->{"f-level3", "k-level4"}
}
2.5 子圖
dot支持將一組元素組合成一個子圖,且一個圖形可以包含一個及多個子圖。
使用子圖需要注意以下兩點:
- 子圖node無法在主圖rank中使用。
- 子圖命名必須以:"cluster"作爲前綴。
digraph demo_subgraph {
bgcolor=beige
fontcolor=gray10
fontsize=12
label="this is demo"
rankdir=TB
/* 特別注意: 子圖命名必須以"cluster"爲前綴 */
subgraph "cluster_g1" {
label="g1"
bgcolor=cadetblue
"level1"->"level2"->"level3"->"level4"
}
subgraph "cluster_g2" {
label="g2"
bgcolor=cornsilk
"level2"
"d-level2"
"e-level2"
}
subgraph "cluster_g3" {
label="g3"
bgcolor=cornsilk
"level3"
"f-level3"
"g-level3"
"h-level3"
"i-level3"
"j-level3"
}
"a-level1"->"d-level2"
"e-level2"->{"h-level3", "k-level4"}
"b-level1"->{"e-level2", "f-level3", "i-level3", "k-level4"}
"c-level1"->{"d-level2", "g-level3", "h-level3"}
"j-level3"->{"f-level3", "k-level4"}
}
2.6 其他用法
2.6.1 label使用html標籤
digraph html {
abc [shape=none, margin=0, label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR><TD ROWSPAN="3"><FONT COLOR="red">hello</FONT><BR/>world</TD>
<TD COLSPAN="3">b</TD>
<TD ROWSPAN="3" BGCOLOR="lightgrey">g</TD>
<TD ROWSPAN="3">h</TD>
</TR>
<TR><TD>c</TD>
<TD PORT="here">d</TD>
<TD>e</TD>
</TR>
<TR><TD COLSPAN="3">f</TD>
</TR>
</TABLE>>];
}
2.6.2 使用label定義子節點
digraph structs {
node [shape=record];
struct1 [shape=record,label="<f0> left|<f1> middle|<f2> right"];
struct2 [shape=record,label="<f0> one|<f1> two"];
struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
}
2.7 UML
ps 以下內容摘自: 【dot 語言畫類圖和 UML 關係】https://www.jianshu.com/p/58333e9314ff
2.7.1 類圖
digraph Class{
rankdir=BT; // 箭頭從下到上
// 默認方形
node [shape = "record", fontname = "Consolas"]
// 默認空箭頭
edge [arrowhead = "empty", fontname = "Consolas"]
// + 公有 - 私有 # 保護 ~ 包級(默認) \l左對齊換行
people [label = "{people
| +name: String\l
-age: int\l
| +getAge(): int\l}"]
// o- 表示接口
study [label = "{o- study}"]
// 繼承 extends
student -> people
// 實現 implements
student -> study [style="dashed"]
}
2.7.2 一對多
digraph {
1 -> n [
arrowhead = "crow"
taillabel="1 "
headlabel="n "
]
}
2.7.3 多對多
digraph {
1 -> n [
dir = "both"
arrowtail = "crow"
arrowhead = "crow"
taillabel="n "
headlabel="n "
]
}
2.7.4 UML(統一建模語言)關係
digraph UML{
rankdir=LR
// 設置字體防止亂碼
fontname = "Microsoft YaHei"
node [fontname = "Microsoft YaHei"]
edge [fontname = "Microsoft YaHei"]
子類 -> 父類
[label = "1繼承泛化
Generalization
extends"
arrowhead = "empty"]
接口[label = "接口
interface"]
實現 -> 接口
[label = "2實現
Realization
implements "
arrowhead = "empty"
style="dashed"]
主體 -> 工具
[label = "3依賴
Dependency"
arrowhead = "vee"
style="dashed"]
主人 -> 被擁有
[label = "4.1關聯
Association"
arrowhead = "vee"]
A -> B
[label = "4.2雙向關聯"
arrowhead = "none"]
C -> C
[label = "4.3自身關聯"
arrowhead = "vee"]
成員 -> 整體
[label = "5聚合
Aggregation"
dir = "both"
arrowtail = "vee"
arrowhead = "odiamond"]
部分 -> 總體
[label = "6.組合
Composition"
dir = "both"
arrowhead = "diamond"
arrowtail = "vee"]
}
2.8 高級用法
ps 內容摘自【使用graphviz繪製流程圖(2015版)http://icodeit.org/2015/11/using-graphviz-drawing/?from=timeline】
2.8.1 軟件模塊組成圖
IDP支持層爲一個相對獨立的子系統,其中包括如數據庫管理器,配置信息管理器等模塊,另外爲了提供更大的靈活性,將很多其他的模塊抽取出來作爲外部模塊,而支持層提供一個模塊管理器,來負責加載/卸載這些外部的模塊集合。
這些模塊間的關係較爲複雜,並且有部分模塊關係密切,應歸類爲一個子系統中,上圖對應的dot腳本爲:
digraph idp_modules{
rankdir = TB;
fontname = "Microsoft YaHei";
fontsize = 12;
node [ fontname = "Microsoft YaHei", fontsize = 12, shape = "record" ];
edge [ fontname = "Microsoft YaHei", fontsize = 12 ];
subgraph cluster_sl{
label="IDP支持層";
bgcolor="mintcream";
node [shape="Mrecord", color="skyblue", style="filled"];
network_mgr [label="網絡管理器"];
log_mgr [label="日誌管理器"];
module_mgr [label="模塊管理器"];
conf_mgr [label="配置管理器"];
db_mgr [label="數據庫管理器"];
};
subgraph cluster_md{
label="可插拔模塊集";
bgcolor="lightcyan";
node [color="chartreuse2", style="filled"];
mod_dev [label="開發支持模塊"];
mod_dm [label="數據建模模塊"];
mod_dp [label="部署發佈模塊"];
};
mod_dp -> mod_dev [label="依賴..."];
mod_dp -> mod_dm [label="依賴..."];
mod_dp -> module_mgr [label="安裝...", color="yellowgreen", arrowhead="none"];
mod_dev -> mod_dm [label="依賴..."];
mod_dev -> module_mgr [label="安裝...", color="yellowgreen", arrowhead="none"];
mod_dm -> module_mgr [label="安裝...", color="yellowgreen", arrowhead="none"];
}
2.8.2 狀態圖
有限自動機示意圖
上圖是一個簡易有限自動機,接受a及a結尾的任意長度的串。其腳本定義如下:
digraph automata_0 {
size = "8.5, 11";
fontname = "Microsoft YaHei";
fontsize = 10;
node [shape = circle, fontname = "Microsoft YaHei", fontsize = 10];
edge [fontname = "Microsoft YaHei", fontsize = 10];
0 [ style = filled, color=lightgrey ];
2 [ shape = doublecircle ];
0 -> 2 [ label = "a " ];
0 -> 1 [ label = "other " ];
1 -> 2 [ label = "a " ];
1 -> 1 [ label = "other " ];
2 -> 2 [ label = "a " ];
2 -> 1 [ label = "other " ];
"Machine: a" [ shape = plaintext ];
}
形狀值爲plaintext的表示不用繪製邊框,僅展示純文本內容,這個在繪圖中,繪製指示性的文本時很有用,如上圖中的Machine: a。
- OSGi中模塊的生命週期圖
OSGi中,模塊具有生命週期,從安裝到卸載,可能的狀態具有已安裝,已就緒,正在啓動,已啓動,正在停止,已卸載等。如下圖所示:
digraph module_lc{
rankdir=TB;
fontname = "Microsoft YaHei";
fontsize = 12;
node [fontname = "Microsoft YaHei", fontsize = 12, shape = "Mrecord", color="skyblue", style="filled"];
edge [fontname = "Microsoft YaHei", fontsize = 12, color="darkgreen" ];
installed [label="已安裝狀態"];
resolved [label="已就緒狀態"];
uninstalled [label="已卸載狀態"];
starting [label="正在啓動"];
active [label="已激活(運行)狀態"];
stopping [label="正在停止"];
start [label="", shape="circle", width=0.5, fixedsize=true, style="filled", color="black"];
start -> installed [label="安裝"];
installed -> uninstalled [label="卸載"];
installed -> resolved [label="準備"];
installed -> installed [label="更新"];
resolved -> installed [label="更新"];
resolved -> uninstalled [label="卸載"];
resolved -> starting [label="啓動"];
starting -> active [label=""];
active -> stopping [label="停止"];
stopping -> resolved [label=""];
}
digraph finite_state_machine {
rankdir = LR;
size = "8,5"
node [shape = doublecircle];
LR_0 LR_3 LR_4 LR_8;
node [shape = circle];
LR_0 -> LR_2 [ label = "SS(B)" ];
LR_0 -> LR_1 [ label = "SS(S)" ];
LR_1 -> LR_3 [ label = "S($end)" ];
LR_2 -> LR_6 [ label = "SS(b)" ];
LR_2 -> LR_5 [ label = "SS(a)" ];
LR_2 -> LR_4 [ label = "S(A)" ];
LR_5 -> LR_7 [ label = "S(b)" ];
LR_5 -> LR_5 [ label = "S(a)" ];
LR_6 -> LR_6 [ label = "S(b)" ];
LR_6 -> LR_5 [ label = "S(a)" ];
LR_7 -> LR_8 [ label = "S(b)" ];
LR_7 -> LR_5 [ label = "S(a)" ];
LR_8 -> LR_6 [ label = "S(b)" ];
LR_8 -> LR_5 [ label = "S(a)" ];
}
2.8.3 時序圖
digraph G {
rankdir="LR";
node[shape="point", width=0, height=0];
edge[arrowhead="none", style="dashed"]
{
rank="same";
edge[style="solided"];
LC[shape="plaintext"];
LC -> step00 -> step01 -> step02 -> step03 -> step04 -> step05;
}
{
rank="same";
edge[style="solided"];
Agency[shape="plaintext"];
Agency -> step10 -> step11 -> step12 -> step13 -> step14 -> step15;
}
{
rank="same";
edge[style="solided"];
Agent[shape="plaintext"];
Agent -> step20 -> step21 -> step22 -> step23 -> step24 -> step25;
}
step00 -> step10 [label="sends email new custumer", arrowhead="normal"];
step11 -> step01 [label="declines", arrowhead="normal"];
step12 -> step02 [label="accepts", arrowhead="normal"];
step13 -> step23 [label="forward to", arrowhead="normal"];
step24 -> step14;
step14 -> step04 [arrowhead="normal"];
}
rankdir="LR"表示,佈局從左L到右R。可以看到,在代碼中有{}括起來的部分。
{
rank="same";
edge[style="solided"];
Agency[shape="plaintext"];
Agency -> step10 -> step11 -> step12 -> step13 -> step14 -> step15;
}
每一個rank="same"的block中的所有節點都會在同一條線上。我們設置了所有的線爲虛線,但是在該block中,將線改爲solided。
通過上面幾篇博客的介紹,大致瞭解了dot語言的語法以及作用。發現它還是非常強大和靈活的。只要能夠發揮你的組合及想象能力,肯定是能夠滿足一些基本文檔圖表的繪製需求。而且還擺脫了普通製圖功能繁瑣的排版工作,還是非常適合有一定編程基礎的用戶使用的。簡直是一門很值得去學習瞭解的腳本語言。
更多的學習可以參考
官方文檔地址:https://graphviz.gitlab.io/documentation/
官方pdf學習文檔地址:https://graphviz.gitlab.io/_pages/pdf/dotguide.pdf
三、學習Graphviz
3.1 What is Graphviz?
官網描述如下所示:
Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains.
翻譯過來大致如下:
Graphviz是一個開源的圖形可視化軟件。圖形可視化是將結構信息表示爲抽象圖形和網絡圖的一種方法。它在網絡、生物信息學、軟件工程、數據庫和web設計、機器學習以及其他技術領域的可視化界面中有着重要的應用。
3.2 Features
The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in useful formats, such as images and SVG for web pages; PDF or Postscript for inclusion in other documents; or display in an interactive graph browser. Graphviz has many useful features for concrete diagrams, such as options for colors, fonts, tabular node layouts, line styles, hyperlinks, and custom shapes.
翻譯過來大致如下:
Graphviz 佈局程序使用簡單的文本語言對圖形進行描述,並以有用的格式製作圖表,例如用於網頁的圖像和svg;用於包含在其他文檔中的pdf或postscript;或顯示在交互式圖形瀏覽器中。graphviz對於具體的圖表有許多有用的特性,例如顏色、字體、表格節點佈局、線條樣式、超鏈接和自定義形狀的選項。
3.3 Roadmap
dot - “hierarchical” or layered drawings of directed graphs. This is the default tool to use if edges have directionality.
翻譯過來大致如下:
點-有向圖的層次或分層圖。如果邊具有方向性,則這是要使用的默認工具。
這就是我們需要的dot文件。
3.4 Download
我們去下面這個【Graphviz軟件下載地址 : https://graphviz.gitlab.io/download/】
因爲電腦是window系統,所以找到【Stable 2.38 Windows install packages】進行下載,地址爲:https://graphviz.gitlab.io/_pages/Download/Download_windows.html
進入到下載地址,選擇合適的安裝包下載即可,這裏我選擇zip格式下載,地址爲:https://graphviz.gitlab.io/_pages/Download/windows/graphviz-2.38.zip
如下所示:
打開該壓縮包,內容如下所示:
我將壓縮包解壓到目錄:C:\Program Files (x86)\graphviz-2.38\release,如下所示
3.5 使用gvedit
進入到 C:\Program Files (x86)\graphviz-2.38\release\bin 目錄,打開gvedit.exe程序,下面的GVedit.html是指導文檔
打開gvedit程序,如下所示。
-
參考下面的GVedit.html是指導文檔
-
File:
-
New: Creates a blank text window. You can use it to write a description of a graph in the DOT language. New graphs are not saved to disk until you save them manually.
-
Open: Opens a file dialogue box to select and load a DOT file into the editor. Each file is opened in a new window and does not affect other open graphs.
-
Save: Saves the active graph to disk. If the active graph is new and does not have a name, it opens a Save As dialogue to allow you to specify the file’s name before saving.
-
Save as: Opens a Save As dialogue to save the active graph. You can save a graph under different names but you will always be working with the most recently saved graph.
-
Close: Closes the active graph window. If there are any unsaved changes, you get a dialogue box asking if you want to save the changes before closing the graph.
-
-
Edit:
-
Undo : This command rolls back the last thing that you have done within the active graph.
-
Cut : Removes selected text and keeps it in the clipboard.
-
Copy: Copies selected text to the clipboard.
-
Paste: Inserts the text from the clipboard into the cursor position on the active graph.
-
Find: Opens the find dialogue box to allow you to locate desired text in a graph.
-
-
Graphviz
-
Run: Processes the active graph with the last attributes that were used for it. If the active graph has never been processed before, it opens the settings window.
-
Settings: Opens the settings window. Details of this window are given below.
-
-
View
-
Cascade: Sets the style for handling multiple windows to cascade, in which each new window overlaps the previous one.
-
Tile: Sets the style for handling multiple windows to tiling, in which the open graph windows partition the root window.
-
-
Help
-
Help: Opens a manual page describing how to use this program.
-
Graphviz on net: Opens a browser window on the Graphviz home page.
-
About GVedit: Provides version information about the program.
-
3.5.1 使用gvedit打開dot文件
按照上面的指導文檔,我們打開之前的x.dot文件,如下所示
x.dot 源代碼
digraph "com.amap.api.col.sl3.x" {
graph [bgcolor="transparent",pad="0.555"];
node [color="#00BFC4",fillcolor="#00BFC440",fontcolor="#333333",fontname=Helvetica,shape=box,style=filled];
edge [fontname=Helvetica];
rankdir = TB;
"x" [color="#CCCC66",fillcolor="#CCCC6640"];
"x:finalize()" [color="#000033",fillcolor="#00003340"];
"x:setRenderer(GLSurfaceView$Renderer)" [color="#993399",fillcolor="#99339940"];
"x$i:start()" [color="#66CC33",fillcolor="#66CC3340"];
"x" -> "x:finalize()" [color="#0033FF",fontcolor="#0033FF"];
"x" -> "x:setRenderer(GLSurfaceView$Renderer)" [color="#9999FF",fontcolor="#9999FF"];
"x:setRenderer(GLSurfaceView$Renderer)" -> "x$i:start()" [color="#669933",fontcolor="#669933"];
}
生成的圖像
3.5.2 使用gvedit編輯dot文件
比如我們【File】–>【New】
然後彈出下面的編輯界面
接着我們現在寫一段dot腳本代碼,如下所示
digraph demo_graph {
bgcolor=beige
fontcolor=gray10
fontsize=12
label="this is demo"
rankdir=TB
{rank=same; "level1" "a-level1" "b-level1" "c-level1"}
{rank=same; "level2" "d-level2" "e-level2"}
{rank=same; "level3" "f-level3" "g-level3" "h-level3" "i-level3" "j-level3"}
{rank=same; "level4" "k-level4"}
"level1"->"level2"->"level3"->"level4"
"a-level1"->"d-level2"
"e-level2"->{"h-level3", "k-level4"}
"b-level1"->{"e-level2", "f-level3", "i-level3", "k-level4"}
"c-level1"->{"d-level2", "g-level3", "h-level3"}
"j-level3"->{"f-level3", "k-level4"}
}
然後我們點擊【Layout】按鈕,即可轉圖像
轉完之後,如下所示
四、VSCode 安裝Graphviz 插件
現在VSCode這麼火,當然也想看看VSCode是否支持Graphviz 。打開搜索下Graphviz 插件,如下所示:
安裝下這兩個插件試一試
- Graphviz (dot) language support for Visual Studio Code
- Graphviz Preview
如下圖所示,安裝好了:
在VSCode上面也可以通過安裝插件的方式打開和編輯dot文件了。
-
源代碼
-
預覽圖
五、參考資料
-
節點、邊和圖形屬性 Node, Edge and Graph Attributes : https://graphviz.gitlab.io/_pages/doc/info/attrs.html
-
The DOT Language :https://www.cnblogs.com/itzxy/p/7860073.html
-
在 org-mode 中使用 Graphviz 畫關係圖 https://coldnew.github.io/787b7d73/
-
【使用graphviz繪製流程圖(2015版)http://icodeit.org/2015/11/using-graphviz-drawing/?from=timeline】
-
dot language 學習筆記:https://www.cnblogs.com/billnote/p/4043267.html
-
官方pdf學習文檔地址:https://graphviz.gitlab.io/_pages/pdf/dotguide.pdf
作者:歐陽鵬 歡迎轉載,與人分享是進步的源泉!
轉載請保留原文地址:https://ouyangpeng.blog.csdn.net/article/details/100925405
☞ 本人QQ: 3024665621
☞ QQ交流羣: 123133153
☞ github.com/ouyangpeng
☞ [email protected]
————————————————
版權聲明:本文爲CSDN博主「歐陽鵬」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://ouyangpeng.blog.csdn.net/article/details/100700954