流程圖 Graphviz - Graph Visualization Software


0.目錄

1.參考

https://www.processon.com/  應該值得一試

知乎 用什么軟件畫流程圖?

9款國內外垂直領域的在線作圖工具[可代替visio]

程序員必知的七個圖形工具

說到流程圖還是再次提及一下,我們之前說到的Graphviz 。

Graphviz (英文:Graph Visualization Software的縮寫)是一個由AT&T實驗室啟動的開源工具包,用於繪制DOT語言腳本描述的圖形。它也提供了供其它軟件使用的庫。

它的主要特點是代碼生成圖像,並且足夠的簡單。

 

2.Graphviz

(1)下載安裝

http://graphviz.org/Download.php 最下方 agree

Windows
Stable and development Windows Install packages

 (2)添加環境變量

path添加: D:\Program Files (x86)\Graphviz2.38\bin

新開cmd:dot -?

 (3)中文支持

在 Windows 上設定 Graphviz 中文字型

只要你用 UTF-8 的編碼來儲存描述關係圖的 dot 檔,Graphviz 也可以產生包含中文的關係圖。但 Windows 版的 Graphviz 似乎沒有設定好 fontconfig,因此會找不到中文字型,只要設定好 fontconfig 即可解決。依照預設安裝路徑,設定檔在 C:\Program Files\Graphviz 2.21\etc\fonts\fonts.conf,找到以下這行:

    <dir>#FONTDIR#</dir>
改成 Windows 字型檔的路徑:

    <dir>C:\WINDOWS\Fonts</dir>
Graphviz 就可以使用中文了!但注意目前似乎只能輸入英文的字型名稱,範例如下:

digraph g {
    node[fontname = "PMingLiu"];
    "中文" -> "英文";
}
View Code

(4) 可以運行gvedit.exe寫入代碼,f5直接預覽效果

(5) python庫,其實用處不大

https://pypi.python.org/pypi/graphviz

 

3.參考文檔

官網: http://graphviz.org/Documentation.php

 

使用DOT語言和Graphviz繪圖(翻譯)

一次性批量定義屬性

    node [color=Red,fontname=Courier,shape=box] //All nodes will this shape and colour
    edge [color=Blue, style=dashed] //All the lines look like this

標 題: 【合集】dot language Graphviz流程圖的問題

  (連線連在角上)

  portPos headport tailport 這幾個屬性

畫圖神器--graphviz

digraph login3times{

    edge[fontname="Microsoft YaHei"]
    node[shape=box, fontname="Microsoft YaHei" size="20,20"]
    fontname="Microsoft YaHei"
    label="三次登錄流程圖"

4.語法注意事項

(1)框圖為node,默認形狀 ellipse 橢圓形, shape = box 長方形,diamond 菱形,circle 圓形

(2)連線為edge,箭頭方向 [dir=forward, back, both, or none]

(3)在有必要的時候加雙引號,如:“do sth”, "func()"

(4)注釋為 //, 或 /*   */

(5)不方便之處:

A -> B -> C ->D[label=to] ,則會在三條連線上都添加 to 字樣

對比:

A -> B

B -> C[label=to]

C ->D

 

5.綜合應用

//G:\pydata\pycode>dot eg.dot -Tpng -o eg.png
digraph graphname
{
//rankdir=LR
node[fontname = "simsun"]
fontname="Microsoft YaHei"
label="代理IP獲取流程圖"

START[label="入口get_mimvp()" shape=box]
END[label=出口ip_port_type_tuple_list, shape=box]
JUDGE[label="feature_vectors == []" color=Blue, fontsize=24, shape=diamond]

START -> JUDGE
                {rank=same; "extract_features()", "load_mimvp()"}
                JUDGE -> "extract_features()"[label=True tailport=w]// headport=n]
                        "extract_features()"[style=filled, fillcolor=orange]
                JUDGE -> "load_mimvp()"[label=False tailport=s headport=n]
                    
"extract_features()" -> "load_mimvp()"[label=return, fontcolor=red, dir=forward]   //dir=forward, back, both, or none        


port_src_list[style=filled, fillcolor=yellow]
port_list[style=filled, fillcolor=green]

"load_mimvp()" -> {ip_list, type_list, port_src_list}
                                        port_src_list -> port_list
{rank=same; ip_list, type_list, port_list} -> "merge_result" -> END


    subgraph cluster1
    {
    label=子圖1_特征提取
    
    "invoke extract_features()"[style=filled, fillcolor=orange]
    judge[label="filepath is not None" color=Blue, shape=diamond]
    feature_vectors[style=filled, fillcolor=red]
    
    "invoke extract_features()" -> judge
        judge -> "load_images_from_filepath()"[label=True tailport=w]
        judge -> "load_images_from_src_list()"[label=False tailport=s]
        {rank=same; "load_images_from_filepath()", "load_images_from_src_list()"}
            "load_images_from_filepath()" -> "split_image()"[label=img_list]
            "load_images_from_src_list()" -> "split_image()"[label=img_list]
                "split_image()" -> "build_vector()"[label="split_imgs"]
                    "build_vector()" -> feature_vectors[label="item = {input: vector}"]   // -> "load_mimvp()"
    } 

 
    subgraph cluster2
    {
    label=子圖2_余弦相似度比較
    port_src[style=filled, fillcolor=yellow]
    port[style=filled, fillcolor=green]

    port_src -> "get_port()" -> "load_image_from_src()" -> "invoke split_image()" -> "invoke build_vector()"
        "invoke build_vector()" -> "cos_similarity()"[label="vector\nfeature_vectors", fontcolor=red]
            "cos_similarity()" -> port
    }  
}
View Code

代碼另存為eg.dot, 編碼utf-8

在命令行中運行:G:\pydata\pycode>dot eg.dot -Tpng -o eg.png

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM