442 views
owned this note
# HackMD Graphviz #
###### tags: `MCL Notebook` `hackmd` `graphviz` ######
> 說明的時候,如果相關訊息(link)在後面,可以直接使用這種方式[^description_file],做出像論文一樣的編號
[^description_file]: [:link:](https://graphviz.gitlab.io/_pages/doc/info/attrs.html) 參數說明文件
### References ###
1. [:link:](https://graphviz.gitlab.io/_pages/doc/info/attrs.html) 參數說明文件
2. [:link:](https://graphs.grevian.org/example) 簡單範例
3. [:link:](https://graphviz.readthedocs.io/en/stable/index.html) Python 類似功能說明文件
## Access ##
### Graphviz 在 Markdown (CodiMD) 上的操作 ###
基礎結構如下:
```graphviz
[Graphviz 語法]
```
Hello world 如下:
```graphviz
digraph {
hello -> world;
}
```
你可以在 CodiMD 或是任何有支援 Graphviz 的 Markdown 平台上透過以上手法來操作。
### Graphviz 在 Python 上的操作 ###
## 實際案例 ##
1. 走鐘的二元樹
若沒有加入任何參數下,二元樹的表達可能會不如我們預期:
```graphviz
digraph{
A->B;
A->C;
B->D;
B->E;
C->F;
C->G;
}
```
我們會發現 `B` 與 `C` 節點沒有確實落在他們的子節點中間。此時設法加入關於邊的 `weight` 參數:
```graphviz
digraph{
A->B [weight=0.5];
A->C [weight=0.5];
B->D;
B->E;
C->F;
C->G;
}
```
此時就是一個勻稱的二元樹。
2.