文章目录
- Command Line
- Flags = 命令行参数
- `-G`*name*[=*value*] - G开头都是设置图属性
- `-N`*name*[=*value*] - N开头的设置节点属性
- `-E`*name*[=*value*] - E开头是设置边属性
- `-K`*layout* - K开头就是布局引擎
- `-T`format[:renderer[:formatter]]
- `-V` - 版本
- `-l`*library* - 渲染前导
- `-n`[*num*] - neato和fdp需要
- `-o`outfile - 输出文件
- `-O` - 自动命名输出文件
- `-P` - 生成插件配置
- `-q` - 抑制警告信息
- `-s`[*scale*] - neato和fdp需要
- `-v` - 详细模式
- `-x` - neato需要 - 设置修剪
- `-y` - 翻转纵轴
- `-?` - 打印用法
- Environment Variables - 环境变量
参考文章:https://graphviz.org/doc/info/command.html
Command Line
DOT rendering programs
and utilities
.
All Graphviz programs have a similar invocation
:
DOT渲染程序
和实用程序
。
所有Graphviz程序都有类似的调用方式
:
cmd [ flags ] [ input files ]
cmd
是命令的名字,[ flags ]
是可选的标志(flags),而[ input files ]
是可选的输入文件。
For example:
$ dot -Tsvg input.dot
将 DOT 语言描述的图形转换为 SVG(Scalable Vector Graphics)格式。
If no input files
are supplied, the program reads from stdin.
如果没有提供
输入文件
,则程序将从标准输入中读取。
For example:
$ echo 'digraph { a -> b }' | dot -Tsvg > output.svg
Generates:
Flags = 命令行参数
-G
name[=value] - G开头都是设置图属性
Set a graph attribute, with default value = true
For example,
设置一个 图属性,默认 值 为
true
例如,
$ echo 'digraph { a -> b }' | dot -Tsvg -Gfontcolor=red -Glabel="My favorite letters"
Overrides the default fontcolor
and label
attributes of the graph, producing a red legend:
覆盖了图的默认
fontcolor
和label
属性,生成了一个红色的图例
-N
name[=value] - N开头的设置节点属性
Set a default node attribute
, with default value = true
.
For example,
设置一个默认的节点属性,默认值为
true
。例如,
$ echo 'digraph { a -> b }' | dot -Tsvg -Nfontcolor=red -Nshape=rect
Overrides the default node fontcolor
and shape
attributes, producing rectangular nodes with red text:
覆盖 默认节点的 fontcolor
和 shape
属性,生成 带有红色文本的矩形节点:
-E
name[=value] - E开头是设置边属性
Set a default edge attribute, with default value = true
.
For example,
设置默认 边属性,默认 值 为
true
。例如:
$ echo 'digraph { a -> b }' | dot -Tsvg -Ecolor=red -Earrowhead=diamond
Overrides
the default edge color
and arrowhead
attributes, producing red edges with a diamond arrowhead
:
覆盖
默认的边 color
和 arrowhead
属性,生成 带有菱形箭头的红色边
:
-K
layout - K开头就是布局引擎
Specifies
which default layout engine to use, overriding the default from the command name
.
For example, running dot -Kneato
is equivalent
to running neato
.
指定
使用的默认布局引擎,覆盖命令名
的默认值。
例如,运行dot -Kneato
相当于运行neato
。
-T
format[:renderer[:formatter]]
Set output language
to one of the supported formats.
By default, attributed dot is produced.
将“输出语言”设置为支持的格式之一。
默认情况下,会生成带属性的dot格式。
Depending on how Graphviz was built
, there may be multiple renderers
for generating a particular output format
, and multiple formatters
for creating the final output
.
根据“Graphviz的编译方式”,可能有“多个渲染器”用于生成“特定输出格式”,也可能有“多个格式化器”用于“创建最终输出”。
这里说了两个东西renderer,这个可以叫做渲染引擎;还有一个东西叫做formatters,这个可以叫做格式引擎。
For example, a typical installation
can produce PNG output using either the Cairo
or GD
library.
例如,
典型的安装
可以使用Cairo
或GD
库生成PNG输出。
The desired rendering engine
can be specified
after a colon
.
所需的
渲染引擎
可以在冒号之后指定
。
If there are multiple formatting engines
available, the desired one can be specified in a similar fashion
after the rendering engine.
Thus, -Tpng:cairo
specifies PNG output produced by Cairo
(using the Cairo's default formatter
), and -Tpng:cairo:gd
specifies PNG output produced by Cairo
formatted using the GD
library.
如果可用
多个格式化引擎
,则可以在渲染引擎之后以类似的方式
指定所需的格式化引擎。因此,
-Tpng:cairo
指定由Cairo
生成的 PNG 输出(使用Cairo
的默认格式化器),而-Tpng:cairo:gd
指定由Cairo
使用GD
库进行格式化的 PNG 输出。
If no renderer
is specified, or a renderer
but no formatter
, the default one is invoked
.
The flag -Tformat:
produces a list of all of the renderers
available for the specified
format, the first one listed with a prefix matching format
being the default.
Using the -v
flag, described below, will print which format
, renderer
, and formatter
are actually used.
如果没有指定
渲染器
,或者只指定了渲染器
而没有指定格式化器
,那么就会调用
默认的渲染器。标志
-Tformat:
会生成指定格式可用的所有渲染器
的列表,其中第一个与指定格式前缀匹配的渲染器是默认的渲染器。使用下面描述的
-v
标志,可以打印出实际使用的格式
、渲染器
和格式化器
。
-V
- 版本
Emit
version information and exit.
For example:
显示版本信息并退出。
例如:
$ dot -V
dot - graphviz version 2.47.1 (20210417.1919)
-l
library - 渲染前导
User-supplied
, device-dependent
library text.
Multiple flags may be given.
These strings are passed to the code generator
at the beginning of output
.
For PostScript output, they are treated as file names
whose content will be included in the preamble
after the standard preamble
.
If library is the empty string ""
, the standard preamble
is not emitted
.
用户提供的、设备相关的
库文本
。可以给出多个标志。
这些字符串在“输出开始时”传递给“代码生成器”。
对于PostScript输出,它们被视为“文件名”,其内容将在“标准前言”之后包含在“前言”中。
如果library是空字符串
""
,则不会“发出”标准“前言”。
在Graphviz中,library text
通常指的是用户提供的、特定于设备的库文本。
这些文本通常用于定制图形的渲染过程,特别是在输出为特定格式(如PostScript)时。
这些文本可以包含一些预定义的指令或脚本,这些指令或脚本将在图形渲染的特定阶段被执行,以影响最终的输出效果。
具体来说,对于PostScript输出,library text
可能被当作文件名来处理,其内容将在标准前导之后被包含到前导中。
前导(preamble)在PostScript中是一段代码,它通常包含定义字体、颜色、图形状态等的指令,这些指令在渲染图形之前被执行。
如果用户提供的library
是一个空字符串,那么标准的前导将不会被发出。
这意味着图形将不会包含任何默认的前导设置,只包含用户自定义的library text
。
在Graphviz的DOT语言描述中,你可以通过特定的属性或指令来指定这些library text
。
然后,在渲染过程中,Graphviz会使用这些文本来生成最终的图形输出。
需要注意的是,library text
的使用通常需要对Graphviz和特定输出格式(如PostScript)有深入的了解,以便正确地编写和使用这些文本。
不正确的使用可能会导致图形渲染错误或不可预测的输出。
-n
[num] - neato和fdp需要
Sets no-op
flag in neato.
If set, neato assumes nodes have already been positioned
and all nodes have a pos attribute giving the positions.
It then performs an optional adjustment
to remove node-node overlap
, depending on the value of the overlap attribute, computes the edge layouts
, depending on the value of the splines attribute, and emits the graph in the appropriate format
.
If num is supplied
, the following actions occur:
-
num = 1
- Equivalent to
-n
.
- Equivalent to
-
num > 1
在neato中设置
no-op
标志。如果设置了该标志,neato将假定节点已经
定位
完成,并且所有节点都有一个pos属性,该属性给出了节点的位置。然后,根据overlap属性的值,执行
可选的调整
以消除节点之间的重叠
,根据splines属性的值计算边的布局
,并以适当的格式输出图形。如果提供了num值,则执行以下操作:
-o
outfile - 输出文件
Write output to file outfile.
For example,
将输出写入文件 outfile。例如,
$ echo 'digraph { a -> b }' | dot -Tsvg -o output.svg
Generates output.svg
:
By default, output goes to stdout.
默认情况下,输出会发送到标准输出。
-O
- 自动命名输出文件
Automatically generate output file names
based on the input file name
and the various output formats specified by the -T flags.
For example,
根据
输入文件名
和由**-T**标志指定的各种输出格式,自动生成输出文件names
。例如,
$ dot -Tsvg -O ~/family.dot ~/debug.dot
Generates ~/family.dot.svg
and ~/debug.dot.svg
files.
生成
~/family.dot.svg
和~/debug.dot.svg
文件。
这里说的是啥意思?
如果你用的是小写的o,那么你是需要指定输出的文件名的。
如果你用的是大写的O,那么你不需要了,输出的文件名是根据输入的文件名来确定的。
-P
- 生成插件配置
Automatically generate a graph that shows the plugin configuration
of the current executable
.
e.g.
自动生成一个图形,展示
当前可执行文件的插件配置
。例如:
$ dot -P -Tsvg -o plugins.svg
执行了上面的代码之后,出现的效果,如下图所示:
-q
- 抑制警告信息
Suppress warning messages.
抑制警告消息。
-s
[scale] - neato和fdp需要
Set input scale
to scale.
If this value is omitted
, 72.0
is used.
This number is used to convert the point coordinate units
used in the pos attribute into inches
, which is what is expected by neato and fdp
.
Thus, feeding the output of a graph laid out by one program into neato or fdp
almost always requires this flag.
Ignored if the -n
flag is used.
将
输入比例
设置为scale。如果省略此值,则使用
72.0
。此数字用于将pos属性中使用的
点坐标单位
转换为英寸
,这是neato和fdp所期望的
。因此,
将一个程序布局的图形输出传递给neato或fdp
几乎总是需要此标志。如果使用
-n
标志,则忽略此标志。
-v
- 详细模式
Verbose mode
详细模式
-x
- neato需要 - 设置修剪
In neato, on input, prune
isolated nodes
and peninsulas
.
This removes uninteresting graph structure
and produces a less cluttered drawing
.
在neato中,在输入时,
修剪
孤立的节点
和半岛
。这移除了
不重要的图形结构
,并生成了一个不那么杂乱的绘图
。
在Graphviz中,neato
是一个布局程序,它用于自动排列图形节点以产生美观的布局。
在neato
布局过程中,prune
操作是一个重要的步骤。
当英文中说到“In neato, on input, prune
isolated nodes
and peninsulas
.” 时,它指的是在neato
布局算法处理输入图形时,会执行一个==“修剪”步骤==。
这个步骤的目的是去除孤立的节点(即没有与其他节点连接的节点)以及半岛(即只通过一个节点与其他部分连接的子图)。
为什么要进行这样的修剪呢?
因为在图形可视化中,孤立的节点和半岛可能不会对图形的整体结构和信息传达产生重要贡献,但它们可能会使得最终的图形看起来更杂乱,不容易理解。
通过修剪这些元素,neato
可以生成一个更简洁、更易于理解的图形布局。
因此,当你看到“This removes uninteresting graph structure
and produces a less cluttered drawing
.” 这样的描述时,它就是在解释修剪操作的效果:通过移除不重要的图形结构,neato
能够生成一个不那么杂乱的图形布局,从而更容易让用户理解和分析图形的结构和信息。
总的来说,prune
操作是Graphviz中neato
布局程序的一个重要特性,用于优化图形的视觉呈现,提高可读性。
“prune”的发音表示为“普润”。
-y
- 翻转纵轴
By default, the coordinate system
used in generic output formats, such as attributed dot, extended dot, plain and plain-ext, is the standard cartesian system
with the origin in the lower left corner
, and with increasing y coordinates as points move from bottom to top.
If the -y
flag is used, the coordinate system is inverted, so that increasing values of y correspond to movement from top to bottom.
默认情况下,通用输出格式(如属性dot、扩展dot、plain和plain-ext)中使用的
坐标系
是标准笛卡尔坐标系
,其原点位于左下角
,y坐标随着点从底部向上移动而增加。如果使用
-y
标志,坐标系将反转,因此y值的增加将对应从上到下的移动。
-?
- 打印用法
Print usage
information, then exit.
If multiple -T
flags are given, drawings of the graph
are emitted in each of the specified formats.
Multiple -o
flags can be used to specify the output file for each format
.
If there are more formats than files, the remaining formats
are written to stdout.
Note that the -G
, -N
and -E
flags override any initial attribute declarations
in the input graph, i.e., those attribute statements appearing before any node, edge or subgraph definitions.
In addition, these flags cause the related attributes to be permanently attached to the graph
.
Thus, if attributed dot is used for output
, the graph will have these attributes.
打印
用法
信息,然后退出。如果提供了多个
-T
标志,则会在指定的每种格式中输出图形的绘图
。可以使用多个
-o
标志来指定每种格式的输出文件
。如果格式数量多于文件数量,
剩余格式
的输出将写入标准输出。请注意,
-G
、-N
和-E
标志会覆盖输入图中任何初始属性声明
,即那些出现在任何节点、边或子图定义之前的属性语句。此外,这些标志会将相关属性
永久附加到图形上
。因此,如果使用带属性的dot进行
输出
,则图形将具有这些属性。
Environment Variables - 环境变量
GDFONTPATH
List of pathnames
giving directories which a program should search for fonts.
Overridden by DOTFONTPATH.
Used only if Graphviz is not built with the fontconfig
library
列出
pathnames
提供的目录,程序应在这些目录中搜索字体。可通过DOTFONTPATH覆盖。
仅在Graphviz未使用
fontconfig
库构建时使用
描述了在Graphviz中,如何指定程序搜索字体的目录。
首先,它提到了pathnames
的列表,这个列表包含了程序应该搜索字体的目录
。
接着,它说明了可以通过设置环境变量DOTFONTPATH
来覆盖这个列表中的目录。
也就是说,如果DOTFONTPATH
被设置了,那么程序将优先在这个环境变量指定的目录中搜索字体,而不是pathnames
列表中的目录。
最后,指出这个pathnames
列表只在Graphviz没有使用fontconfig
库构建的情况下才会被使用。
fontconfig
是一个用于处理字体的库,它可以提供更灵活和强大的字体管理功能。
如果Graphviz是使用fontconfig
构建的,那么它可能会使用fontconfig
来管理字体,而不是简单地按照pathnames
列表中的目录来搜索。
简而言之,解释了Graphviz在搜索字体时的一种机制,并指出了这个机制在Graphviz不同构建方式下的应用情况。
GDFONTPATH
是 Graphviz 的一个环境变量,用于指定 Graphviz 绘图工具在查找字体时应该搜索的目录路径。
当 Graphviz 需要渲染文本时(例如,在节点或边上显示标签),它会查找可用的字体文件。
GDFONTPATH
环境变量允许用户指定一个或多个目录,Graphviz 将在这些目录中搜索字体文件。
在 Windows 系统中,你可以通过以下步骤设置 GDFONTPATH
环境变量:
- 打开“控制面板” -> “系统” -> “高级系统设置”。
- 点击“环境变量”按钮。
- 在“系统变量”部分,点击“新建”来创建一个新的环境变量。
- 输入变量名
GDFONTPATH
,并在变量值中指定字体文件所在的目录路径
。如果有多个目录,使用分号;
分隔它们。
设置完成后,当你运行 Graphviz 的命令行工具时,它将使用 GDFONTPATH
中指定的目录来查找字体文件。
请注意,GDFONTPATH
主要用于指定 Graphviz 的内建字体
(通常是位图字体)。
如果你使用的是 TrueType 或 OpenType 字体,Graphviz 通常会依赖于操作系统的字体管理系统,而不是通过 GDFONTPATH
来查找这些字体。
在这种情况下,确保所需的字体已经安装在你的操作系统中,并且可以被 Graphviz 正确识别和使用。
Graphviz 的内建字体主要是位图字体
,这些字体是 Graphviz 绘图工具自带的一些字体资源。
然而,具体哪些字体被包含为内建字体可能取决于 Graphviz 的版本和构建配置。
通常,这些内建字体是为了在缺少外部字体支持的情况
下提供基本的文本渲染能力。
由于 Graphviz 的内建字体可能因版本和配置而异,并且这些字体可能并不是用户通常期望的高质量字体
,
因此在实际使用中,用户更可能会选择使用系统安装的 TrueType 或 OpenType 字体。
这些字体提供了更广泛的选择和更高的质量。
为了使用系统安装的字体,用户需要确保这些字体已经正确安装在他们的操作系统中,并且 Graphviz 能够识别和访问这些字体。
在大多数情况下,Graphviz 会利用操作系统的字体管理系统
来查找和使用这些字体。
DOTFONTPATH
List of pathnames
giving directories which a program should search for fonts.
Overridden by fontpath.
Used only if Graphviz is not built with the fontconfig
library
列出
pathnames
提供的目录,程序应在这些目录中搜索字体。通过fontpath覆盖。
仅当Graphviz未使用
fontconfig
库构建时使用
SERVER_NAME
If defined, this indicates that the software is running as a web application
, which restricts access to image files.
如果已定义,则表示该软件作为“Web应用程序”运行,这会限制对图像文件的访问。
在Graphviz中,SERVER_NAME
环境变量用于指定Graphviz服务器的名称。
当使用Graphviz的远程图形化渲染功能时,可以通过设置SERVER_NAME
环境变量来指定连接的目标服务器的名称。
通过设置SERVER_NAME
环境变量,可以确保Graphviz客户端与正确的服务器进行通信和渲染。
这对于需要在分布式系统或远程服务器上生成和渲染图形时特别有用。
这个环境变量的值应该是一个有效的服务器名称,可以是IP地址或者主机名称。
通过设置SERVER_NAME
环境变量,可以在多个服务器之间进行切换,从而实现灵活的图形渲染和处理。
GVBINDIR
Indicates which directory
contains the Graphviz config file
and plug-in libraries
.
If it is defined, the value overrides any other mechanism for finding this directory
.
If Graphviz is properly installed, it should not be needed, though it can be useful for relocation on platforms
not running Linux or Windows.
指示
哪个目录
包含Graphviz的配置文件
和插件库
。如果已定义,该值将覆盖
用于查找此目录的其他任何机制
。如果Graphviz已正确安装,则通常不需要此设置,但它在
非Linux或Windows平台的迁移
中可能很有用。
acyclic
Make directed graphs acyclic
.
使有向图变为无环图。
bcomps
Biconnected components filter
for graphs.
图的
双连通分量过滤器
。
ccomps
Connected components filter
for graphs.
图的
连通分量过滤器
。
cluster
Find clusters
in a graph and augment the graph with this information
.
在图中查找簇,并用这些信息增强图。
diffimg
Calculates intersection
between two images.
计算两张图像之间的交集。
dijkstra
Single-source distance filter.
单源距离过滤器。
dotty
A customizable graph editor.
可定制的图形编辑器。
edgepaint
Edge coloring to disambiguate
crossing edges.
边缘着色以
消除
交叉边缘的歧义。
gc
Count graph components.
计算图的组件数。
gml2gv
GML-DOT converters.
GML-DOT转换器。
graphml2gv
GRAPHML-DOT converter.
GRAPHML-DOT转换器。
gv2gxl
GXL-GV converters.
GXL-GV转换器。
gvcolor
Flow colors through a ranked digraph.
在有向图中流动颜色。
gvedit
Simple graph editor and viewer.
简单的图形编辑器和查看器。
gvgen
Generate graphs.
生成图。
gvmap
Find clusters and create a geographical map highlighting clusters
.
查找
簇
并创建突出显示簇
的地理地图。
gvpack
Merge and pack disjoint graphs.
合并和打包不相交的图。
gvpr
Graph pattern scanning and processing language.
图模式扫描和处理语言。
gxl2gv
GXL-GV converters.
GXL-GV转换器。
lefty
A programmable graphics editor.
可编程图形编辑器。
lneato
A customizable graph editor.
可定制的图形编辑器。
mingle
Fast edge bundling.
快速边捆绑。
mm2gv
Matrix Market-DOT converters.
Matrix Market-DOT转换器。
nop
Pretty-print graph file.
美化打印图形文件。
sccmap
Extract strongly connected components of directed graphs.
提取有向图的强连通分量。
smyrna
Interactive graph viewer
.
交互式图形查看器。
tred
Transitive reduction filter
for directed graphs
.
有向图
的传递归约过滤器
。
unflatten
Adjust directed graphs to improve layout aspect ratio
.
调整
有向图
以改善布局纵横比
。
vimdot
Combined text editor and dot viewer.
文本编辑器和dot查看器结合。