-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot-lang-cheatsheet.html
202 lines (176 loc) · 11.9 KB
/
dot-lang-cheatsheet.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Dot 画图常用语法 — Feng's blog 1.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/custom.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="sqlite剖析(1)——文件格式" href="sqlite-file-format.html" />
<link rel="prev" title="Simhash 算法" href="simhash.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="dot-hua-tu-chang-yong-yu-fa">
<h1>Dot 画图常用语法<a class="headerlink" href="#dot-hua-tu-chang-yong-yu-fa" title="Permalink to this headline">¶</a></h1>
<section id="you-xiang-tu">
<h2>有向图<a class="headerlink" href="#you-xiang-tu" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">digraph</span> <span class="p">{</span>
<span class="n">a</span> <span class="o">-></span> <span class="n">b</span>
<span class="p">}</span>
</pre></div>
</div>
<img alt="_images/dot-digraph.png" src="_images/dot-digraph.png" />
</section>
<section id="wu-xiang-tu">
<h2>无向图<a class="headerlink" href="#wu-xiang-tu" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">graph</span> <span class="p">{</span>
<span class="n">a</span> <span class="o">--</span> <span class="n">b</span>
<span class="p">}</span>
</pre></div>
</div>
<img alt="_images/dot-graph.png" src="_images/dot-graph.png" />
</section>
<section id="tu-shu-xing">
<h2>图属性<a class="headerlink" href="#tu-shu-xing" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">label="My</span> <span class="pre">Graph"</span></code> 给图添加标题。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">rankdir=LR</span></code> 默认图为上下布局,修改为左右布局。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">{rank=same;</span> <span class="pre">a,</span> <span class="pre">b,</span> <span class="pre">c</span> <span class="pre">}</span></code> 将 a, b, c 画到同一个层级上</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">digraph</span> <span class="p">{</span>
<span class="n">label</span><span class="o">=</span><span class="s2">"xyz"</span>
<span class="n">rankdir</span><span class="o">=</span><span class="n">LR</span>
<span class="p">{</span><span class="n">rank</span><span class="o">=</span><span class="n">same</span><span class="p">;</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">}</span>
<span class="n">a</span> <span class="o">-></span> <span class="n">b</span>
<span class="n">b</span> <span class="o">-></span> <span class="n">c</span>
<span class="p">}</span>
</pre></div>
</div>
<img alt="_images/dot-graph-attrs.png" src="_images/dot-graph-attrs.png" />
</section>
<section id="jie-dian-shu-xing">
<h2>节点属性<a class="headerlink" href="#jie-dian-shu-xing" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">label="XXX"</span></code> 修改节点中的文字内容</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">color=red</span></code> 修改节点边框 <a class="reference external" href="http://graphviz.org/doc/info/colors.html">颜色</a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">style=filled,</span> <span class="pre">fillcolor=yellow</span></code> 给节点添加填充色</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">shape</span></code> <a class="reference external" href="http://graphviz.org/doc/info/shapes.html">节点形状</a></p></li>
</ul>
</section>
<section id="bian-shu-xing">
<h2>边属性<a class="headerlink" href="#bian-shu-xing" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">label="XXX"</span></code> 给边添加说明信息</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">color=red</span></code> 修改边 <a class="reference external" href="http://graphviz.org/doc/info/colors.html">颜色</a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">penwidth=2.0</span></code> 修改边宽度</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">style=dotted</span></code> 修改边的样式</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">graph</span> <span class="p">{</span>
<span class="n">rankdir</span><span class="o">=</span><span class="n">LR</span>
<span class="n">a</span> <span class="p">[</span><span class="n">label</span><span class="o">=</span><span class="s2">"Foo"</span><span class="p">]</span>
<span class="n">b</span> <span class="p">[</span><span class="n">shape</span><span class="o">=</span><span class="n">box</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">filled</span><span class="p">,</span> <span class="n">fillcolor</span><span class="o">=</span><span class="n">yellow</span><span class="p">]</span>
<span class="n">a</span> <span class="o">--</span> <span class="n">b</span> <span class="o">--</span> <span class="n">c</span> <span class="p">[</span><span class="n">color</span><span class="o">=</span><span class="n">blue</span><span class="p">]</span>
<span class="n">b</span> <span class="o">--</span> <span class="n">d</span> <span class="p">[</span><span class="n">style</span><span class="o">=</span><span class="n">dotted</span><span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
<img alt="_images/dot-node-attrs.png" src="_images/dot-node-attrs.png" />
<p>常见的节点和边样式属性:</p>
<img alt="_images/dot-style.png" src="_images/dot-style.png" />
</section>
<section id="record-jie-dian">
<h2>Record 节点<a class="headerlink" href="#record-jie-dian" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">digraph</span> <span class="n">structs</span> <span class="p">{</span>
<span class="n">node</span> <span class="p">[</span><span class="n">shape</span><span class="o">=</span><span class="n">record</span><span class="p">];</span>
<span class="n">struct1</span> <span class="p">[</span><span class="n">shape</span><span class="o">=</span><span class="n">record</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s2">"<f0> left|<f1> middle|<f2> right"</span><span class="p">];</span>
<span class="n">struct2</span> <span class="p">[</span><span class="n">shape</span><span class="o">=</span><span class="n">record</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s2">"<f0> one|<f1> two"</span><span class="p">];</span>
<span class="n">struct3</span> <span class="p">[</span><span class="n">shape</span><span class="o">=</span><span class="n">record</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s2">"hello</span><span class="se">\n</span><span class="s2">world |{ b |{c|<here> d|e}| f}| g | h"</span><span class="p">];</span>
<span class="n">struct1</span><span class="p">:</span><span class="n">f1</span> <span class="o">-></span> <span class="n">struct2</span><span class="p">:</span><span class="n">f0</span><span class="p">;</span>
<span class="n">struct1</span><span class="p">:</span><span class="n">f2</span> <span class="o">-></span> <span class="n">struct3</span><span class="p">:</span><span class="n">here</span><span class="p">;</span>
<span class="n">struct2</span> <span class="o">-></span> <span class="n">struct3</span>
<span class="p">}</span>
</pre></div>
</div>
<img alt="_images/dot-record.png" src="_images/dot-record.png" />
</section>
<section id="ming-ling-xing-can-shu">
<h2>命令行参数<a class="headerlink" href="#ming-ling-xing-can-shu" title="Permalink to this headline">¶</a></h2>
<p>将图源码保存为 <code class="docutils literal notranslate"><span class="pre">input.dot</span></code> 文件,执行以下命令生成 png 图:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>dot -Tpng -o output.png input.dot
</pre></div>
</div>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Dot 画图常用语法</a><ul>
<li><a class="reference internal" href="#you-xiang-tu">有向图</a></li>
<li><a class="reference internal" href="#wu-xiang-tu">无向图</a></li>
<li><a class="reference internal" href="#tu-shu-xing">图属性</a></li>
<li><a class="reference internal" href="#jie-dian-shu-xing">节点属性</a></li>
<li><a class="reference internal" href="#bian-shu-xing">边属性</a></li>
<li><a class="reference internal" href="#record-jie-dian">Record 节点</a></li>
<li><a class="reference internal" href="#ming-ling-xing-can-shu">命令行参数</a></li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/dot-lang-cheatsheet.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="https://cn.bing.com/search" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>
$('#searchbox').show(0);
document.getElementsByClassName('search')[0].addEventListener('submit', function(event) {
event.preventDefault();
var form = event.target;
var input = form.querySelector('input[name="q"]');
var value = input.value;
var q = 'ensearch=1&q=site%3Achanfung032.github.io++' + value;
var url = form.action + '?' + q;
window.location.href = url;
});
</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2017, chanfung032.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.1.2</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/dot-lang-cheatsheet.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>