属性
下表描述了各种Graphviz工具所使用的属性。 表格列出了属性名称、使用该属性的图形组件(节点、边等)以及属性的类型(表示该类型合法值的字符串)。在适用的情况下,表格还提供了属性的默认值、数值属性的最小允许设置值,以及该属性的某些使用限制。
请注意属性名称是区分大小写的。 对于属性值通常也是如此,除非另有说明。
所有Graphviz属性都通过名称-值对来指定。因此,要设置节点abc的color,可以使用
digraph {
abc [color = red]
}类似地,要设置边abc -> def的箭头样式,可以使用:
digraph {
abc -> def [arrowhead = diamond]
}关于属性设置的更多详细信息可以在DOT语言的描述中找到。
目前,大多数与设备无关的单位要么是英寸,要么是点,我们采用每英寸72点的标准。
注意:某些属性,例如
dir或arrowtail,在
DOT中用于无向图时会产生歧义,因为边的头尾
没有实际意义。按照惯例,当无向边首次出现时,
DOT
解析器会将左侧节点指定为尾节点,右侧节点指定为
头节点。例如,边A -- B的尾节点是A
头节点是B。用户需要负责以一致的方式处理这类
边。如果该边后续以以下格式再次出现
graph {
B -- A [taillabel = "tail"]
}绘图会将尾部标签附加到节点A上。
为了避免在使用这些属性时可能产生的混淆,建议用户使用有向图。
如果必须使图形显示为无向图,可以通过设置dir、arrowtail或arrowhead属性来实现。
这些工具接受标准的C语言表示法来定义int和double类型。
对于bool类型,TRUE值由true或yes(不区分大小写)以及任何非零整数表示,FALSE值由false或no(不区分大小写)和零表示。
此外,还有各种特殊类型,如arrowType、color、point和rankdir。这些类型的合法值将在最后给出。
Used By(适用对象)列字段表示该属性适用于哪些图形组件。
在注释字段中,标注为只写表示该属性仅用于输出,不会被任何布局程序使用或读取。
| 名称 | 使用方 | 类型 | 默认值 | 最小值 | 描述和备注 |
|---|---|---|---|---|---|
_background |
Graphs | xdot | <none> |
A string in the xdot format specifying an arbitrary background.
|
|
area |
Nodes, Clusters | double | 1.0 |
>0 |
Indicates the preferred area for a node or empty cluster. patchwork only. |
arrowhead |
Edges | arrowType | normal |
Style of arrowhead on the head node of an edge. | |
arrowsize |
Edges | double | 1.0 |
0.0 |
Multiplicative scale factor for arrowheads. |
arrowtail |
Edges | arrowType | normal |
Style of arrowhead on the tail node of an edge. | |
bb |
Clusters, Graphs | rect | Bounding box of drawing in points. write only. | ||
beautify |
Graphs | bool | false |
Whether to draw leaf nodes uniformly in a circle around the root node in sfdp.. sfdp only. | |
bgcolor |
Graphs, Clusters | color, colorList | <none> |
Canvas background color. | |
center |
Graphs | bool | false |
Whether to center the drawing in the output canvas. | |
charset |
Graphs | string | "UTF-8" |
Character encoding used when interpreting string input as a text label.. | |
class |
Edges, Nodes, Clusters, Graphs | string | "" |
Classnames to attach to the node, edge, graph, or cluster's SVG element. svg only. | |
cluster |
Clusters, Subgraphs | bool | false |
Whether the subgraph is a cluster. | |
clusterrank |
Graphs | clusterMode | local |
Mode used for handling clusters. dot only. | |
color |
Edges, Nodes, Clusters | color, colorList | black |
Basic drawing color for graphics, not text. | |
colorscheme |
Edges, Nodes, Clusters, Graphs | string | "" |
A color scheme namespace: the context for interpreting color names. | |
comment |
Edges, Nodes, Graphs | string | "" |
Comments are inserted into output. | |
compound |
Graphs | bool | false |
If true, allow edges between clusters. dot only. | |
concentrate |
Graphs | bool | false |
If true, use edge concentrators. | |
constraint |
Edges | bool | true |
If false, the edge is not used in ranking the nodes. dot only. | |
Damping |
Graphs | double | 0.99 |
0.0 |
Factor damping force motions.. neato only. |
decorate |
Edges | bool | false |
Whether to connect the edge label to the edge with a line. | |
defaultdist |
Graphs | double | 1+(avg. len)*sqrt(|V|) |
epsilon |
The distance between nodes in separate connected components. neato only. |
dim |
Graphs | int | 2 |
2 |
Set the number of dimensions used for the layout. neato, fdp, sfdp only. |
dimen |
Graphs | int | 2 |
2 |
Set the number of dimensions used for rendering. neato, fdp, sfdp only. |
dir |
Edges | dirType | forward (directed) none (undirected) |
Edge type for drawing arrowheads. | |
diredgeconstraints |
Graphs | string, bool | false |
Whether to constrain most edges to point downwards. neato only. | |
distortion |
Nodes | double | 0.0 |
-100.0 |
Distortion factor for shape=polygon.
|
dpi |
Graphs | double | 96.0 |
0.0 |
Specifies the expected number of pixels per inch on a display device. bitmap output, svg only. |
edgehref |
Edges | escString | "" |
Synonym for edgeURL.
map, svg only.
|
|
edgetarget |
Edges | escString | <none> |
Browser window to use for the edgeURL link.
map, svg only.
|
|
edgetooltip |
Edges | escString | "" |
Tooltip annotation attached to the non-label part of an edge. cmap, svg only. | |
edgeURL |
Edges | escString | "" |
The link for the non-label parts of an edge. map, svg only. | |
epsilon |
Graphs | double | .0001 * # nodes (mode == KK) .0001 (mode == major) .01 (mode == sgd) |
Terminating condition. neato only. | |
esep |
Graphs | addDouble, addPoint | +3 |
Margin used around polygons for purposes of spline edge routing. neato, fdp, sfdp, osage, circo, twopi only. | |
fillcolor |
Nodes, Edges, Clusters | color, colorList | lightgrey (nodes) black (clusters) |
Color used to fill the background of a node or cluster. | |
fixedsize |
Nodes | bool, string | false |
Whether to use the specified width and height attributes to choose node size (rather than sizing to fit the node contents). | |
fontcolor |
Edges, Nodes, Graphs, Clusters | color | black |
Color used for text. | |
fontname |
Edges, Nodes, Graphs, Clusters | string | "Times-Roman" |
Font used for text. | |
fontnames |
Graphs | string | "" |
Allows user control of how basic fontnames are represented in SVG output. svg only. | |
fontpath |
Graphs | string | <system-dependent> |
Directory list used by libgd to search for bitmap fonts. | |
fontsize |
Edges, Nodes, Graphs, Clusters | double | 14.0 |
1.0 |
Font size, in points, used for text. |
forcelabels |
Graphs | bool | true |
Whether to force placement of all xlabels, even if overlapping.
|
|
gradientangle |
Nodes, Clusters, Graphs | int | 0 |
0 |
If a gradient fill is being used, this determines the angle of the fill. |
group |
Nodes | string | "" |
Name for a group of nodes, for bundling edges avoiding crossings.. dot only. | |
head_lp |
Edges | point | Center position of an edge's head label. write only. | ||
headclip |
Edges | bool | true |
If true, the head of an edge is clipped to the boundary of the head node. | |
headhref |
Edges | escString | "" |
Synonym for headURL.
map, svg only.
|
|
headlabel |
Edges | lblString | "" |
Text label to be placed near head of edge. | |
headport |
Edges | portPos | center |
Indicates where on the head node to attach the head of the edge. | |
headtarget |
Edges | escString | <none> |
Browser window to use for the headURL link.
map, svg only.
|
|
headtooltip |
Edges | escString | "" |
Tooltip annotation attached to the head of an edge. cmap, svg only. | |
headURL |
Edges | escString | "" |
If defined, headURL is output as part of the head label of the edge.
map, svg only.
|
|
height |
Nodes | double | 0.5 |
0.02 |
Height of node, in inches. |
href |
Graphs, Clusters, Nodes, Edges | escString | "" |
Synonym for URL.
map, postscript, svg only.
|
|
id |
Graphs, Clusters, Nodes, Edges | escString | "" |
Identifier for graph objects. map, postscript, svg only. | |
image |
Nodes | string | "" |
Gives the name of a file containing an image to be displayed inside a node. | |
imagepath |
Graphs | string | "" |
A list of directories in which to look for image files. | |
imagepos |
Nodes | string | "mc" |
Controls how an image is positioned within its containing node. | |
imagescale |
Nodes | bool, string | false |
Controls how an image fills its containing node. | |
inputscale |
Graphs | double | <none> |
Scales the input positions to convert between length units. neato, fdp only. | |
K |
Graphs, Clusters | double | 0.3 |
0 |
Spring constant used in virtual physical model. fdp, sfdp only. |
label |
Edges, Nodes, Graphs, Clusters | lblString | "\N" (nodes) "" (otherwise) |
Text label attached to objects. | |
label_scheme |
Graphs | int | 0 |
0 |
Whether to treat a node whose name has the form |edgelabel|* as a special node representing an edge label..
sfdp only.
|
labelangle |
Edges | double | -25.0 |
-180.0 |
The angle (in degrees) in polar coordinates of the head & tail edge labels.. |
labeldistance |
Edges | double | 1.0 |
0.0 |
Scaling factor for the distance of headlabel / taillabel from the head / tail nodes..
|
labelfloat |
Edges | bool | false |
If true, allows edge labels to be less constrained in position. | |
labelfontcolor |
Edges | color | black |
Color used for headlabel and taillabel..
|
|
labelfontname |
Edges | string | "Times-Roman" |
Font for headlabel and taillabel.
|
|
labelfontsize |
Edges | double | 14.0 |
1.0 |
Font size of headlabel and taillabel.
|
labelhref |
Edges | escString | "" |
Synonym for labelURL.
map, svg only.
|
|
labeljust |
Graphs, Clusters | string | "c" |
Justification for graph & cluster labels. | |
labelloc |
Nodes, Graphs, Clusters | string | "t" (clusters) "b" (root graphs) "c" (nodes) |
Vertical placement of labels for nodes, root graphs and clusters. | |
labeltarget |
Edges | escString | <none> |
Browser window to open labelURL links in.
map, svg only.
|
|
labeltooltip |
Edges | escString | "" |
Tooltip annotation attached to label of an edge. cmap, svg only. | |
labelURL |
Edges | escString | "" |
If defined, labelURL is the link used for the label of an edge.
map, svg only.
|
|
landscape |
Graphs | bool | false |
If true, the graph is rendered in landscape mode. | |
layer |
Edges, Nodes, Clusters | layerRange | "" |
Specifies layers in which the node, edge or cluster is present. | |
layerlistsep |
Graphs | string | "," |
The separator characters used to split attributes of type layerRange into a list of ranges..
|
|
layers |
Graphs | layerList | "" |
A linearly ordered list of layer names attached to the graph. | |
layerselect |
Graphs | layerRange | "" |
Selects a list of layers to be emitted. | |
layersep |
Graphs | string | ":\t " |
The separator characters for splitting the layers attribute into a list of layer names..
|
|
layout |
Graphs | string | "" |
Which layout engine to use. | |
len |
Edges | double | 1.0 (neato) 0.3 (fdp) |
Preferred edge length, in inches. neato, fdp only. | |
levels |
Graphs | int | INT_MAX |
0.0 |
Number of levels allowed in the multilevel scheme. sfdp only. |
levelsgap |
Graphs | double | 0.0 |
strictness of neato level constraints. neato only. | |
lhead |
Edges | string | "" |
Logical head of an edge. dot only. | |
lheight |
Graphs, Clusters | double | Height of graph or cluster label, in inches. write only. | ||
linelength |
Graphs | int | 128 |
60 |
How long strings should get before overflowing to next line, for text output.. |
lp |
Edges, Graphs, Clusters | point | Label center position. write only. | ||
ltail |
Edges | string | "" |
Logical tail of an edge. dot only. | |
lwidth |
Graphs, Clusters | double | Width of graph or cluster label, in inches. write only. | ||
margin |
Nodes, Clusters, Graphs | double, point | <device-dependent> |
For graphs, this sets x and y margins of canvas, in inches. | |
maxiter |
Graphs | int | 100 * # nodes (mode == KK) 200 (mode == major) 30 (mode == sgd) 600 (fdp) |
Sets the number of iterations used. neato, fdp only. | |
mclimit |
Graphs | double | 1.0 |
Scale factor for mincross (mc) edge crossing minimiser parameters. dot only. | |
mindist |
Graphs | double | 1.0 |
0.0 |
Specifies the minimum separation between all nodes. circo only. |
minlen |
Edges | int | 1 |
0 |
Minimum edge length (rank difference between head and tail). dot only. |
mode |
Graphs | string | major |
Technique for optimizing the layout. neato only. | |
model |
Graphs | string | shortpath |
Specifies how the distance matrix is computed for the input graph. neato only. | |
newrank |
Graphs | bool | false |
Whether to use a single global ranking, ignoring clusters. dot only. | |
nodesep |
Graphs | double | 0.25 |
0.02 |
In dot, nodesep specifies the minimum space between two adjacent nodes in the same rank, in inches.
|
nojustify |
Graphs, Clusters, Nodes, Edges | bool | false |
Whether to justify multiline text vs the previous text line (rather than the side of the container).. | |
normalize |
Graphs | double, bool | false |
normalizes coordinates of final layout. neato, fdp, sfdp, twopi, circo only. | |
notranslate |
Graphs | bool | false |
Whether to avoid translating layout to the origin point. neato only. | |
nslimit |
Graphs | double | Sets number of iterations in network simplex applications. dot only. | ||
nslimit1 |
Graphs | double | Sets number of iterations in network simplex applications. dot only. | ||
oneblock |
Graphs | bool | false |
Whether to draw circo graphs around one circle.. circo only. | |
ordering |
Graphs, Nodes | string | "" |
Constrains the left-to-right ordering of node edges.. dot only. | |
orientation |
Nodes, Graphs | double, string | 0.0"" |
-360.0 |
node shape rotation angle, or graph orientation. |
outputorder |
Graphs | outputMode | breadthfirst |
Specify order in which nodes and edges are drawn. | |
overlap |
Graphs | string, bool | true |
Determines if and how node overlaps should be removed. fdp, neato, sfdp, circo, twopi only. | |
overlap_scaling |
Graphs | double | -4 |
-1e+10 |
Scale layout by factor, to reduce node overlap.. prism, neato, sfdp, fdp, circo, twopi only. |
overlap_shrink |
Graphs | bool | true |
Whether the overlap removal algorithm should perform a compression pass to reduce the size of the layout. prism only. | |
pack |
Graphs | bool, int | false |
Whether each connected component of the graph should be laid out separately, and then the graphs packed together.. | |
packmode |
Graphs | packMode | node |
How connected components should be packed. | |
pad |
Graphs | double, point | 0.0555 (4 points) |
Inches to extend the drawing area around the minimal area needed to draw the graph. | |
page |
Graphs | double, point | Width and height of output pages, in inches. | ||
pagedir |
Graphs | pagedir | BL |
The order in which pages are emitted. | |
pencolor |
Clusters | color | black |
Color used to draw the bounding box around a cluster. | |
penwidth |
Clusters, Nodes, Edges | double | 1.0 |
0.0 |
Specifies the width of the pen, in points, used to draw lines and curves. |
peripheries |
Nodes, Clusters | int | <shape default> (nodes) 1 (clusters) |
0 |
Set number of peripheries used in polygonal shapes and cluster boundaries. |
pin |
Nodes | bool | false |
Keeps the node at the node's given input position. neato, fdp only. | |
pos |
Edges, Nodes | point, splineType | Position of node, or spline control points. neato, fdp only. | ||
quadtree |
Graphs | quadType, bool | normal |
Quadtree scheme to use. sfdp only. | |
quantum |
Graphs | double | 0.0 |
0.0 |
If quantum > 0.0, node label dimensions will be rounded to integral multiples of the quantum.
|
rank |
Subgraphs | rankType | Rank constraints on the nodes in a subgraph. dot only. | ||
rankdir |
Graphs | rankdir | TB |
Sets direction of graph layout. dot only. | |
ranksep |
Graphs | double, doubleList | 0.5 (dot) 1.0 (twopi) |
0.02 |
Specifies separation between ranks. dot, twopi only. |
ratio |
Graphs | double, string | Sets the aspect ratio (drawing height/drawing width) for the drawing. | ||
rects |
Nodes | rect | Rectangles for fields of records, in points. write only. | ||
regular |
Nodes | bool | false |
If true, force polygon to be regular.. | |
remincross |
Graphs | bool | true |
If there are multiple clusters, whether to run edge crossing minimization a second time.. dot only. | |
repulsiveforce |
Graphs | double | 1.0 |
0.0 |
The power of the repulsive force used in an extended Fruchterman-Reingold. sfdp only. |
resolution |
Graphs | double | 96.0 |
0.0 |
Synonym for dpi..
bitmap output, svg only.
|
root |
Graphs, Nodes | string, bool | <none> (graphs) false (nodes) |
Specifies nodes to be used as the center of the layout. twopi, circo only. | |
rotate |
Graphs | int | 0 |
If rotate=90, sets drawing orientation to landscape.
|
|
rotation |
Graphs | double | 0 |
Rotates the final layout counter-clockwise by the specified number of degrees. sfdp only. | |
samehead |
Edges | string | "" |
Edges with the same head and the same samehead value are aimed at the same point on the head.
dot only.
|
|
sametail |
Edges | string | "" |
Edges with the same tail and the same sametail value are aimed at the same point on the tail..
dot only.
|
|
samplepoints |
Nodes | int | 8 (output) 20 (overlap and image maps) |
Gives the number of points used for a circle/ellipse node. | |
scale |
Graphs | double, point | Scales layout by the given factor after the initial layout. neato, twopi only. | ||
searchsize |
Graphs | int | 30 |
During network simplex, the maximum number of edges with negative cut values to search when looking for an edge with minimum cut value.. dot only. | |
sep |
Graphs | addDouble, addPoint | +4 |
Margin to leave around nodes when removing node overlap. fdp, neato, sfdp, osage, circo, twopi only. | |
shape |
Nodes | shape | ellipse |
Sets the shape of a node. | |
shapefile |
Nodes | string | "" |
A file containing user-supplied node content. | |
showboxes |
Edges, Nodes, Graphs | int | 0 |
0 |
Print guide boxes for debugging. dot only. |
sides |
Nodes | int | 4 |
0 |
Number of sides when shape=polygon.
|
size |
Graphs | double, point | Maximum width and height of drawing, in inches. | ||
skew |
Nodes | double | 0.0 |
-100.0 |
Skew factor for shape=polygon.
|
smoothing |
Graphs | smoothType | "none" |
Specifies a post-processing step used to smooth out an uneven distribution of nodes.. sfdp only. | |
sortv |
Graphs, Clusters, Nodes | int | 0 |
0 |
Sort order of graph components for ordering packmode packing..
|
splines |
Graphs | bool, string | Controls how, and if, edges are represented. | ||
start |
Graphs | startType | "" |
Parameter used to determine the initial layout of nodes. neato, fdp, sfdp only. | |
style |
Edges, Nodes, Clusters, Graphs | style | "" |
Set style information for components of the graph. | |
stylesheet |
Graphs | string | "" |
A URL or pathname specifying an XML style sheet, used in SVG output. svg only. | |
tail_lp |
Edges | point | Position of an edge's tail label, in points.. write only. | ||
tailclip |
Edges | bool | true |
If true, the tail of an edge is clipped to the boundary of the tail node. | |
tailhref |
Edges | escString | "" |
Synonym for tailURL..
map, svg only.
|
|
taillabel |
Edges | lblString | "" |
Text label to be placed near tail of edge. | |
tailport |
Edges | portPos | center |
Indicates where on the tail node to attach the tail of the edge. | |
tailtarget |
Edges | escString | <none> |
Browser window to use for the tailURL link.
map, svg only.
|
|
tailtooltip |
Edges | escString | "" |
Tooltip annotation attached to the tail of an edge. cmap, svg only. | |
tailURL |
Edges | escString | "" |
If defined, tailURL is output as part of the tail label of the edge.
map, svg only.
|
|
target |
Edges, Nodes, Graphs, Clusters | escString, string | <none> |
If the object has a URL, this attribute determines which window of the browser is used for the URL..
map, svg only.
|
|
TBbalance |
Graphs | string | '' |
Which rank to move floating (loose) nodes to. dot only. | |
tooltip |
Nodes, Edges, Clusters, Graphs | escString | "" |
Tooltip (mouse hover text) attached to the node, edge, cluster, or graph. cmap, svg only. | |
truecolor |
Graphs | bool | Whether internal bitmap rendering relies on a truecolor color model or uses. bitmap output only. | ||
URL |
Edges, Nodes, Graphs, Clusters | escString | <none> |
Hyperlinks incorporated into device-dependent output. map, postscript, svg only. | |
vertices |
Nodes | pointList | Sets the coordinates of the vertices of the node's polygon, in inches. write only. | ||
viewport |
Graphs | viewPort | "" |
Clipping window on final drawing. | |
voro_margin |
Graphs | double | 0.05 |
0.0 |
Tuning margin of Voronoi technique. neato, fdp, sfdp, twopi, circo only. |
weight |
Edges | int, double | 1 |
0(dot,twopi)1(neato,fdp) |
Weight of edge. |
width |
Nodes | double | 0.75 |
0.01 |
Width of node, in inches. |
xdotversion |
Graphs | string |
Determines the version of xdot used in output.
xdot only.
|
||
xlabel |
Edges, Nodes | lblString | "" |
External label for a node or edge. | |
xlp |
Nodes, Edges | point | Position of an exterior label, in points. write only. | ||
z |
Nodes | double | 0.0 |
-MAXFLOAT-1000 |
Z-coordinate value for 3D layouts and displays. |
_background
xdot 格式 specifying an arbitrary background
类型: xdot, 默认值: <none>
在渲染过程中,画布首先按照bgcolor属性的描述进行填充。
然后,如果定义了_background,则会在画布上执行字符串中描述的图形操作。
更多信息请参见xdot格式页面。
digraph G {
_background="c 7 -#ff0000 p 4 4 4 36 4 36 36 4 36";
a -> b
}- 图表
area
类型: double, 默认值: 1.0, 最小值: >0
graph {
layout="patchwork"
node [style=filled]
"5c" [area= 5 fillcolor=silver]
"10c" [area= 10 fillcolor=silver]
"20c" [area= 20 fillcolor=silver]
"50c" [area= 50 fillcolor=silver]
"$1" [area=100 fillcolor=gold]
"$2" [area=200 fillcolor=gold]
}- 节点
- 集群
注意: patchwork 专用。
arrowhead
类型: arrowType, 默认值: normal
只有当dir属性为forward或both时才会显示。
参见limitation。
另请参阅:
Valid on:- 边
arrowsize
类型: double, 默认值: 1.0, 最小值: 0.0
digraph {
quiver -> "0.5" [arrowsize=0.5]
quiver -> "1"
quiver -> "2" [arrowsize=2]
quiver -> "3" [arrowsize=3]
}- 边
arrowtail
类型: arrowType, 默认值: normal
只有当dir属性为back或both时才会显示。
参见limitation。
另请参阅:
Valid on:- 边
bb
类型: rect
Valid on:- 集群
- 图表
注意: 仅限写入。
beautify
类型: bool, 默认值: false
是否尝试将叶节点均匀地绘制在根节点周围的圆圈上。
在Graphviz 8.0.1版本之前,这个问题受到Issue 2283的影响:渲染时会少绘制一个必要的扇区,导致第一个和最后一个节点重叠。
示例:
digraph G {
layout="sfdp"
beautify=true
N0 -> {N1; N2; N3; N4; N5; N6}
}digraph G {
layout="sfdp"
beautify=false
N0 -> {N1; N2; N3; N4; N5; N6}
}- 图表
注意: sfdp 专用。
bgcolor
类型: color | colorList, 默认值: <none>
当附加到根图时,此颜色将用作整个画布的背景。
当设置集群属性时,该属性将作为集群的初始背景色。如果集群设置了填充style,则集群的fillcolor会覆盖背景色。
如果该值是一个colorList,则会使用渐变填充。默认情况下是线性填充;设置style=radial将使用径向填充。仅使用两种颜色。如果缺少第二个颜色(冒号后),则使用默认颜色。另请参阅gradientangle属性来设置渐变角度。
对于某些输出格式,例如PostScript,除非显式设置bgcolor,否则不会对根图进行填充。
然而对于位图格式,这些位需要初始化为某个值,因此默认情况下画布会被填充为白色。这意味着如果位图输出被包含在其他文档中,位图边界框内的所有位都将被设置,覆盖页面上已有的任何颜色或图形。如果不希望出现这种效果,并且您只想设置绘制图形时明确分配的位,请设置bgcolor="transparent"。
graph {
bgcolor="lightblue"
label="Home"
subgraph cluster_ground_floor {
bgcolor="lightgreen"
label="Ground Floor"
Lounge
Kitchen
}
subgraph cluster_top_floor {
bgcolor="lightyellow"
label="Top Floor"
Bedroom
Bathroom
}
}- 图表
- 集群
center
类型: bool, 默认值: false
可以是 true 或 false。
- 图表
charset
类型: string, 默认值: "UTF-8"
默认值为 "UTF-8"。其他合法值为:
"utf-8"/"utf8"(默认值)"iso-8859-1"/"ISO_8859-1"/"ISO8859-1"/"ISO-IR-100"/"Latin1"/"l1"/"latin-1""big-5"/"big5": Big-5 中文编码
charset 属性不区分大小写。
请注意,如果输入中使用的字符编码与charset值不匹配,可能会导致输出结果非常奇怪。
无法在Big-5编码环境下使用HTML-like labels。
digraph G {
charset="UTF-8"
"🍔" -> "💩"
}- 图表
class
类型: string, 默认值: ""
结合stylesheet使用CSS类名来为SVG输出添加样式。
支持多个以空格分隔的类。
另请参阅:
示例:
digraph G {
graph [class="cats"];
subgraph cluster_big {
graph [class="big_cats"];
"Lion" [class="yellow social"];
"Snow Leopard" [class="white solitary"];
}
}- 边
- 节点
- 集群
- 图表
注意: svg 仅限。
cluster
类型: bool, 默认值: false
子图簇的渲染方式有所不同,例如dot会在子图簇周围绘制一个方框,但不会在非子图簇周围绘制方框。
示例:
digraph cats {
subgraph cluster_big_cats {
// This subgraph is a cluster, because the name begins with "cluster"
"Lion";
"Snow Leopard";
}
subgraph domestic_cats {
// This subgraph is also a cluster, because cluster=true.
cluster=true;
"Siamese";
"Persian";
}
subgraph not_a_cluster {
// This subgraph is not a cluster, because it doesn't start with "cluster",
// nor sets cluster=true.
"Wildcat";
}
}- 集群
- 子图
clusterrank
类型: clusterMode, 默认值: local
如果 clusterrank=local,名称以 cluster 开头的子图将获得特殊处理。
子图会单独进行布局,然后作为一个整体集成到其父图中,并绘制一个包围矩形框。如果该集群具有label参数,则此标签会显示在矩形框内。
还需注意的是,集群内部可以包含子集群。
模式 clusterrank=global 和 clusterrank=none 看起来是相同的,两者都关闭了特殊的集群处理。
- 图表
注意: dot 专用。
color
类型: color | colorList, 默认值: black
对于后者,请使用
fontcolor属性。
对于边,该值可以是单一颜色或一个colorList。
在后一种情况下,如果colorList没有分数值,则使用平行样条线或直线绘制边线,按照列表中给定的顺序为每种颜色绘制一条线。
头部箭头(如果有)使用列表中的第一种颜色绘制,尾部箭头(如果有)则使用第二种颜色。这支持了绘制反向边的常见情况,但使用平行样条而不是单独路由的多边。
如果使用了任何比例值,颜色将按顺序绘制,每种颜色在边上大致占据其指定的比例部分。
例如,这个图表:
digraph G {
a -> b [dir=both color="red:blue"]
c -> d [dir=none color="green:red;0.25:blue"]
}生成:
digraph G {
subgraph cluster_yellow {
color="yellow"
a [color="red"]
b [color="green"]
}
}生成:
另请参阅:
Valid on:- 边
- 节点
- 集群
colorscheme
类型: string, 默认值: ""
特别是,如果color值的格式为"xxx"或"//xxx",
那么颜色xxx将根据当前配色方案进行评估。
如果未设置配色方案,则使用标准的X11命名方式。
例如,如果colorscheme=oranges9(来自Brewer color schemes),那么color=7将被解释为
color="/oranges9/7",即oranges9配色方案中的第7种颜色。
graph {
node [colorscheme=oranges9] # Apply colorscheme to all nodes
1 [color=1]
2 [color=2]
3 [color=3]
4 [color=4]
5 [color=5]
6 [color=6]
7 [color=7]
8 [color=8]
9 [color=9]
}graph {
node [colorscheme=greens9] # Apply colorscheme to all nodes
1 [color=1]
2 [color=2]
3 [color=3]
4 [color=4]
5 [color=5]
6 [color=6]
7 [color=7]
8 [color=8]
9 [color=9]
}另请参阅:
Valid on:- 边
- 节点
- 集群
- 图表
comment
类型: string, 默认值: ""
依赖于设备。
digraph {
comment="I am a graph"
A [comment="I am node A"]
B [comment="I am node B"]
A->B [comment="I am an edge"]
}输出带注释的SVG:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.47.1 (20210417.1919)
-->
<!-- This is a graph -->
<!-- Pages: 1 -->
<svg width="62pt" height="116pt"
viewBox="0.00 0.00 62.00 116.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 112)">
<polygon fill="white" stroke="transparent" points="-4,4 -4,-112 58,-112 58,4 -4,4"/>
<!-- A -->
<!-- I am node A -->
<g id="node1" class="node">
<title>A</title>
<ellipse fill="none" stroke="black" cx="27" cy="-90" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-86.3" font-family="Times,serif" font-size="14.00">A</text>
</g>
<!-- B -->
<!-- I am node B -->
<g id="node2" class="node">
<title>B</title>
<ellipse fill="none" stroke="black" cx="27" cy="-18" rx="27" ry="18"/>
<text text-anchor="middle" x="27" y="-14.3" font-family="Times,serif" font-size="14.00">B</text>
</g>
<!-- A->B -->
<!-- I am an edge -->
<g id="edge1" class="edge">
<title>A->B</title>
<path fill="none" stroke="black" d="M27,-71.7C27,-63.98 27,-54.71 27,-46.11"/>
<polygon fill="black" stroke="black" points="30.5,-46.1 27,-36.1 23.5,-46.1 30.5,-46.1"/>
</g>
</g>
</svg>
- 边
- 节点
- 图表
compound
类型: bool, 默认值: false
digraph {
compound=true;
subgraph cluster_a {
label="Cluster A";
node1; node3; node5; node7;
}
subgraph cluster_b {
label="Cluster B";
node2; node4; node6; node8;
}
node1 -> node2 [label="1"];
node3 -> node4 [label="2" ltail="cluster_a"];
node5 -> node6 [label="3" lhead="cluster_b"];
node7 -> node8 [label="4" ltail="cluster_a" lhead="cluster_b"];
}- 图表
注意: dot 专用。
concentrate
类型: bool, 默认值: false
这将多重边合并为单一边,并使部分平行边共享部分路径。后一特性目前仅在dot中可用。
仅适用于非连续节点。
digraph {
concentrate=true
a -> b [label="1"]
c -> b
d -> b
}- 图表
constraint
类型: bool, 默认值: true
例如在图中:
digraph G {
a -> c;
a -> b;
b -> c [constraint=false];
}边 b -> c 在层级分配过程中不会添加约束,因此唯一的约束是 a 必须位于 b 和 c 之上,从而生成如下图形:

- 边
注意: dot 专用。
Damping
类型: double, 默认值: 0.99, 最小值: 0.0
在每次迭代中,节点的移动被限制为其潜在运动的这个比例因子。通过设定小于1.0的值,系统会逐渐"冷却",从而防止循环震荡。
- 图表
注意: neato 专用。
decorate
类型: bool, 默认值: false
如果为true,则通过两段折线将边标签附加到边上,先下划线标签,然后转到样条曲线的最近点。
digraph {
a -> a [label="AA" decorate=true]
a -> b [label="AB" decorate=true]
b -> b [label="BB" decorate=false]
}- 边
defaultdist
类型: double, 默认值: 1+(avg. len)*sqrt(|V|), 最小值: epsilon
如果设置得太小,连接的组件可能会重叠。
仅当pack=false时适用。
- 图表
注意: neato 专用。
dim
类型: int, 默认值: 2, 最小值: 2
允许的最大值为10。
- 图表
dimen
类型: int, 默认值: 2, 最小值: 2
允许的最大值为10。
如果同时设置了dimen和dim,后者指定用于布局的维度,前者用于渲染。
如果只设置了dimen,则该值将同时用于布局和渲染维度。
请注意,目前所有的渲染方面都是二维的。这包括节点的形状和大小、重叠消除以及边路由。因此,对于dimen > 2的情况,唯一有效的信息是节点的pos属性。
所有其他坐标都将是二维的,最多只能反映高维点在平面上的投影。
Valid on:- 图表
dir
类型: dirType, 默认值: forward (有向), none (无向)
指示边的哪一端应该用箭头装饰。
箭头的实际样式可以通过arrowhead和arrowtail属性来指定。
参见 limitation。
digraph {
A->B [dir=forward]
C->D [dir=back]
E->F [dir=both]
G->H [dir=none]
}- 边
diredgeconstraints
如果为true,将为最大(启发式)有向无环子图中的每条边生成约束,使得边必须向下指向。
仅在 mode="ipsep" 时有效。
如果 hier,生成类似于与 mode="hier" 一起使用的层级约束。主要区别在于,在后一种情况下仅涉及这些约束,因此可以使用更快的求解器。
- 图表
注意: neato 专用。
在Graphviz代码库中搜索 "diredgeconstraints"
distortion
类型: double, 默认值: 0.0, 最小值: -100.0
正值会使顶部比底部更大;负值则相反。
另请参阅 skew。
graph {
LargeBottom [shape=polygon sides=4 distortion=-.5]
LargeTop [shape=polygon sides=4 distortion=.5]
}- 节点
dpi
类型: double, 默认值: 96.0, 最小值: 0.0
对于bitmap输出,dpi能确保文本渲染在大小和位置上更加精确。
对于SVG输出,dpi确保输出中的尺寸对应正确的点数或英寸数。
- 图表
注意: 位图输出,仅支持svg格式。
edgehref
edgeURL
类型: escString, 默认值: ""
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
edgetarget
edgeURL link
类型: escString, 默认值: <none>
如果边具有URL或edgeURL
属性,edgetarget将决定浏览器使用哪个窗口
来显示附加到边非标签部分的URL。
设置 edgetarget=_graphviz 会在窗口不存在时打开一个新窗口,如果已存在则复用该窗口。
如果未定义,则使用target的值代替。
- 边
注意: 仅适用于map, svg。
edgetooltip
类型: escString, 默认值: ""
- 边
edgeURL
类型: escString, 默认值: ""
edgeURL 会覆盖为该边定义的任何 URL。
此外,edgeURL会在靠近头节点或尾节点处使用,除非分别被headURL或tailURL覆盖。
参见 limitation。
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
epsilon
类型: double, 默认值: .0001 * # nodes (模式 == KK) , .0001 (模式 == major) , .01 (模式 == sgd)
如果所有能量梯度的长度平方都小于epsilon,算法将停止。
- 图表
注意: neato 专用。
esep
类型: addDouble | addPoint, 默认值: +3
- 图表
注意: neato, fdp, sfdp, osage, circo, twopi 仅限这些工具。
fillcolor
类型: color | colorList, 默认值: lightgrey (节点) , black (集群)
假设 style=filled,或填充的 arrowhead。
如果未定义fillcolor,则使用color。
(对于集群,如果未定义color,则使用bgcolor。)
如果这些都未定义,则使用默认值,但以下情况除外:
shape=point或输出格式为MIF时,
默认使用黑色。
如果该值是colorList,则会使用渐变填充。默认情况下是线性填充;设置style=radial将使用径向填充。目前仅使用两种颜色。如果第二个颜色(冒号后)缺失,则使用默认颜色代替。
另请参阅gradientangle属性
用于设置渐变角度。
请注意,如果定义了父图的属性,集群会继承这些属性。
因此,如果父图定义了fillcolor,这将覆盖为集群设置的
color或bgcolor属性。
- 节点
- 边
- 集群
fixedsize
如果false,节点的大小将由包含其标签和图像(如果有)所需的最小宽度和高度决定,并使用margin属性指定的边距。
宽度和高度也必须至少与width和height属性指定的大小相同,这些属性规定了这些参数的最小值。
如果true,节点大小仅由width和height属性的值决定,不会扩展以包含文本标签。如果标签(包括边距)无法适应这些限制,将会显示警告。
如果fixedsize属性设置为shape,
width和height属性也会决定节点形状的大小,
但标签可以大得多。在避免节点重叠时,标签和形状的大小都会被考虑,
但所有连接到该节点的边都会忽略标签,仅接触节点形状。如果标签过大,不会给出警告。
- 节点
fontcolor
类型: color, 默认值: black
- 边
- 节点
- 图表
- 集群
fontname
类型: string, 默认值: "Times-Roman"
这在很大程度上取决于输出格式,以及对于非位图输出(如PostScript或SVG)来说,图形显示或打印时字体的可用性。因此,最好依赖普遍可用的字体,如Times-Roman、Helvetica或Courier。
字体名称的解析方式还取决于处理字体名称解析的底层库。如果Graphviz是使用fontconfig库构建的,那么将使用该库来搜索字体。关于名称解析方式及可用字体,请参阅命令fc-list、fc-match以及其他fontconfig命令。其他系统可能提供自己的字体包,例如OS X的Quartz。
请注意,各种字体属性(如粗细和倾斜)可以内置到字体名称中。遗憾的是,具体语法取决于使用哪种字体系统。因此,使用fontname="times bold italic"将通过主流字体库Pango生成粗斜体的Times字体。或者,fontname="times:italic"将通过fontconfig生成斜体的Times字体,而fontname="times-bold"将通过Quartz生成粗体的Times字体。您需要确定您的Graphviz系统使用的是哪个软件包,并参考相关文档。
如果Graphviz没有使用高级字体库构建,fontname将被视为Type 1或True Type字体文件的名称。如果您指定fontname=schlbk,该工具将在fontpath属性指定的目录中查找名为schlbk.ttf、schlbk.pfa或schlbk.pfb的文件。查找功能确实支持常见字体的各种别名。
digraph {
label="Comic Sans MS"
fontname="Comic Sans MS"
subgraph cluster_a {
label="Courier New"
fontname="Courier New"
Arial [fontname="Arial"];
Arial -> Arial [label="Impact" fontname="Impact"]
}
}- 边
- 节点
- 图表
- 集群
fontnames
类型: string, 默认值: ""
如果fontnames未定义或为hd,则使用fontconfig字体约定。
默认的Times-Roman字体将被映射到系统可用的等效字体,
例如Times New Roman(Windows)或Times(某些Linux系统)。
如果fontnames设置为svg,输出将使用已知的SVG字体名称。
如果fontnames设置为ps,则会直接使用PostScript字体名称如Times-Roman。
在所有情况下,基本的SVG字体serif都会被用作命名字体的后备选项。(因此,一个包含Times-Roman字体的图表可能在SVG输出中通过带有font-family="Times-Roman,serif"属性的<text>标签来表示该文本。)
- 图表
注意: svg 仅限。
fontpath
类型:string, 默认值:<system-dependent>
如果Graphviz未使用fontconfig库构建时使用。
如果未设置fontpath,则会检查环境变量DOTFONTPATH。
如果未设置DOTFONTPATH,则会检查GDFONTPATH。
如果未设置GDFONTPATH,libgd会使用其内置的字体路径。
请注意fontpath是根图的一个属性。
- 图表
fontsize
类型: double, 默认值: 14.0, 最小值: 1.0
digraph {
label="40pt Graph Label"
fontsize="40"
subgraph cluster_a {
label="30pt Cluster Label"
fontsize="30pt"
"20pt Node" [fontsize="20pt"];
"20pt Node"-> "20pt Node" [label="10pt Edge" fontsize="10"]
}
}- 边
- 节点
- 图表
- 集群
forcelabels
xlabels, even if overlapping
类型: bool, 默认值: true
如果为true,则放置所有xlabel属性,即使与节点或其他标签存在一些重叠。
- 图表
gradientangle
类型:int, 默认值:0, 最小值:0
对于线性填充,颜色会沿着由角度和对象中心指定的直线进行渐变。对于径向填充,值为零时颜色会从中心向外径向渐变;对于非零值,颜色会从对象边缘附近的一个点开始渐变,具体位置由该值指定。
如果未设置,默认角度为0。
Valid on:- 节点
- 集群
- 图表
在Graphviz代码库中搜索"gradientangle"
group
类型: string, 默认值: ""
如果一条边的端点属于同一组,即具有相同的group属性,则会设置参数以避免交叉并保持边为直线。
- 节点
注意: dot 专用。
head_lp
类型: point
Valid on:- 边
注意: 仅限写入。
headclip
类型: bool, 默认值: true
否则,边的终点将指向节点的中心,或者如果适用的话,指向端口的中心。
Valid on:- 边
headhref
headURL
类型: escString, 默认值: ""
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
headlabel
类型: lblString, 默认值: ""
参见 limitation。
Valid on:- 边
headport
类型: portPos, 默认值: center
在默认情况下,边会指向节点的中心,然后在节点边界处被裁剪。
参见 limitation。
Valid on:- 边
headtarget
headURL link
类型: escString, 默认值: <none>
如果边具有headURL,
headtarget决定了浏览器使用哪个窗口
来打开该URL。设置headURL=_graphviz会在窗口不存在时打开新窗口,如果窗口已存在则复用该窗口。
如果未定义,则使用target的值。
- 边
注意: 仅适用于map, svg。
headtooltip
类型: escString, 默认值: ""
仅在边具有headURL属性时使用。
另请参阅:
Valid on:- 边
headURL
headURL is output as part of the head label of the edge
类型: escString, 默认值: ""
此外,该值在头节点附近使用,会覆盖任何URL值。
参见 limitation。
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
height
类型: double, 默认值: 0.5, 最小值: 0.02
这被视为节点的初始最小高度。如果
fixedsize为真,这将是节点的最终高度。否则,如果节点标签需要更多高度来适应,节点的高度将增加以包含标签。
如果输出格式是dot,那么赋予height的值将是最终值。
如果节点形状是规则的,宽度和高度将被设置为相同:
- 如果同时设置了
width和height,则使用两者中的较大值。 - 如果显式设置了
width或height中的一个值,则该值将同时用于width和height。 - 如果两者均未明确设置,则使用两个默认值中的较小值。
digraph G {
"default"
"1in" [height=1]
"2in" [height=2]
}另请参阅:
Valid on:- 节点
href
URL
类型: escString, 默认值: ""
另请参阅:
Valid on:- 图表
- 集群
- 节点
- 边
注意: 仅适用于map、postscript、svg格式。
id
类型: escString, 默认值: ""
允许图的作者为图对象提供一个标识符,该标识符将被包含在输出中。
正常的 \N、\E、\G 替换会被应用。
如果提供,提供者有责任确保id值在其预期下游使用中保持唯一性。
请注意,特别是\E不能为多重边提供唯一标识。
如果没有提供id属性,则会使用一个唯一的内部ID。然而,这个值对于图的编写者来说是不可预测的。
如果图表提供了id属性,这将作为内部生成属性的前缀。通过区分内部使用的属性,用户可以在同一文档中包含多个图像映射。
- 图表
- 集群
- 节点
- 边
注意: 仅适用于map、postscript、svg格式。
image
类型: string, 默认值: ""
图像文件必须是受支持的格式之一,通常是JPEG、PNG、GIF、BMP、SVG或Postscript,并且能够转换为所需的输出格式。
文件必须包含图像尺寸信息:
- 位图格式通常已经包含图像尺寸信息。
- PostScript文件必须包含一行以
%%BoundingBox:开头的代码,后跟四个整数,分别指定图像边界框的左下角x和y坐标以及右上角x和y坐标,坐标单位为点。 - SVG图像文件必须包含宽度和高度属性,通常作为svg元素的一部分。这些属性的值应采用浮点数形式,后跟可选单位,例如
width="76pt"。可识别的单位分别是英寸(in)、像素(px)、派卡(pc)、点(pt)、厘米(cm)和毫米(mm)。默认单位为点(pt)。
与shapefile属性不同,图像被视为节点内容而非整个节点。具体来说,图像可以包含在任何形状的节点中,而不仅仅是矩形。
仅支持本地资源的路径。如需使用远程资源的URL,请参阅dot_url_resolve.py脚本。
- 节点
imagepath
类型: string, 默认值: ""
当通过image属性指定或使用类HTML标签中的IMG元素时。
imagepath 应该是一个由(绝对或相对)路径名组成的列表,每个路径名之间用分号 ; (Windows系统)或冒号 : (其他所有操作系统)分隔。
将使用找到给定名称文件的第一个目录来加载图像。
如果未设置imagepath,则图像文件的相对路径名将相对于当前工作目录进行解析。
- 图表
imagepos
类型: string, 默认值: "mc"
imagepos 仅在图像小于包含节点时生效。
默认情况下,内容会在水平和垂直方向上都居中显示。
有效值:
tl- 左上角tc- 顶部居中tr- 右上角ml- 中左mc- 中间居中 (默认)mr- 中右bl- 左下角bc- 底部居中br- 右下角
- 节点
imagescale
通常情况下,图像会保持其自然尺寸(参见dpi),而节点大小会被调整得足够大,以容纳其图像、标签、边距和外围区域。
它的宽度和高度也将至少与其最小width和height相同。然而,如果fixedsize=true,则宽度和高度属性将指定节点的确切大小。
- 在渲染过程中,默认情况下(
imagescale=false),图像会保持其原始尺寸。 - 如果
imagescale=true, 图像会按统一比例缩放(即保持长宽比不变)以适应节点内部。 在给定节点大小的情况下,图像的至少一个维度会尽可能放大。 - 当
imagescale=width时,图像的宽度会被缩放以填满节点的宽度。 - 当
imagescale=height时,相应的属性成立。 - 当
imagescale=both时, 高度和宽度会分别进行缩放以填满节点。
在所有情况下,如果图像的某个维度大于节点对应的维度,则该图像的该维度会按比例缩小以适应节点。
与扩展的情况类似,如果imagescale=true,宽度和高度会按统一比例缩放。
- 节点
inputscale
类型: double, 默认值: <none>
对于支持初始输入位置(由pos属性指定)的布局算法,此属性可用于适当缩放这些值。
默认情况下,fdp和neato将pos的x和y值解释为英寸单位。(注意:neato -n(2)将坐标视为点单位,这是布局算法用于pos属性的单位。)因此,如果图形中的pos属性是以点为单位,则应设置inputscale=72。这也可以通过命令行使用-s标志来设置。
如果未设置,则不进行缩放,输入的单位将被视为英寸。
inputscale=0 等同于 inputscale=72。
- 图表
K
类型: double, 默认值: 0.3, 最小值: 0
它大致对应于理想的边长度(以英寸为单位),因为增加K往往会增加节点之间的距离。
请注意,边属性len可用于覆盖相邻节点的此值。
- 图表
- 集群
label
类型: lblString, 默认值: "\N" (节点), "" (其他情况)
如果节点的shape是record类型,那么标签可以采用特殊格式来描述记录布局。
请注意,节点的默认标签是"\N",因此节点的名称或ID会成为其标签。
从技术上讲,节点的名称可以是HTML字符串,但这并不意味着节点的标签会被解释为HTML-like label。这是因为节点的实际标签是一个普通字符串,它将被存储在节点名称中的原始字节所替换。
要获得类似HTML的标签,标签属性值本身必须是一个HTML字符串。
graph {
label="Vincent van Gogh Paintings"
subgraph cluster_self_portraits {
label="Self-portraits"
spwgfh [label="Self-Portrait with Grey Felt Hat"]
spaap [label="Self-Portrait as a Painter"]
}
subgraph cluster_flowers {
label="Flowers"
sf [label="Sunflowers"]
ab [label="Almond Blossom"]
}
}- 边
- 节点
- 图表
- 集群
label_scheme
|edgelabel|* as a special node representing an edge label.
类型:int, 默认值:0, 最小值:0
- 默认情况下,
label_scheme=0不会产生任何效果。 - 如果
label_scheme=1,sfdp会使用基于惩罚的方法使该类节点靠近其邻居的中心。 - 当
label_scheme=2时,sfdp采用基于惩罚的方法使该类节点靠近其邻居的旧中心位置。 - 最后,
label_scheme=3会触发一个两步处理过程:重叠消除和直线化。
- 图表
注意: sfdp 专用。
在Graphviz代码库中搜索 "label_scheme"
labelangle
类型: double, 默认值: -25.0, 最小值: -180.0
与labeldistance共同决定headlabel / taillabel在极坐标中相对于头部/尾部的位置。
坐标系中的原点是边与节点接触的点。0度的射线从原点沿着边返回,与原点的边平行。
角度以度为单位,指定从0度射线开始的旋转,正角度表示逆时针方向旋转,负角度表示顺时针方向旋转。
Valid on:- 边
labeldistance
类型: double, 默认值: 1.0, 最小值: 0.0
默认距离为10点。
labeldistance 乘以该默认值。
更多详情请参阅labelangle。
- 边
在Graphviz代码库中搜索 "labeldistance"
labelfloat
类型: bool, 默认值: false
特别是,它可能会显示在其他边的上方。
Valid on:- 边
labelfontcolor
类型: color, 默认值: black
如果未设置,默认使用边的fontcolor。
- 边
在Graphviz代码库中搜索"labelfontcolor"
labelfontname
headlabel and taillabel
类型: string, 默认值: "Times-Roman"
如果未设置,默认为边的fontname。
- 边
在Graphviz代码库中搜索 "labelfontname"
labelfontsize
headlabel and taillabel
类型: double, 默认值: 14.0, 最小值: 1.0
字体大小,以点为单位,用于headlabel和
taillabel。
如果未设置,默认使用边的fontsize。
- 边
在Graphviz代码库中搜索"labelfontsize"
labelhref
labelURL
类型: escString, 默认值: ""
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
labeljust
类型: string, 默认值: "c"
- 如果
labeljust=r,标签将在边界矩形内右对齐 - 如果
labeljust=l,左对齐 - 否则标签将居中显示。
请注意,子图会继承其父图的属性。因此,如果根图设置了labeljust=l,子图也会继承这个值。
digraph {
label="l"
labeljust=l
a
}digraph {
label="r"
labeljust=r
b
}digraph {
subgraph cluster_l {
label="l"
labeljust=l
a
}
subgraph cluster_c {
label="c"
labeljust=c
b
}
subgraph cluster_r {
label="r"
labeljust=r
c
}
}- 图表
- 集群
labelloc
类型:string, 默认值:"t" (集群), "b" (根图), "c" (节点)
对于图形和集群,仅允许使用labelloc=t和labelloc=b,分别对应顶部和底部的放置位置。
默认情况下,根图标签位于底部,集群标签位于顶部。
请注意,子图会继承其父图的属性。因此,如果根图设置了labelloc=b,子图也会继承这个值。
对于节点,此属性仅在节点高度大于其标签高度时使用。
如果 labelloc=t、labelloc=c、labelloc=b,标签将分别与节点的顶部对齐、居中或与底部对齐。
默认情况下,标签是垂直居中的。
digraph {
labelloc="t"
label="Title"
a -> b
}digraph {
labelloc="b"
label="Title"
a -> b
}digraph {
label="Graph Title"
subgraph cluster_t {
labelloc="t"
label="Cluster Top"
a -> b
}
subgraph cluster_b {
labelloc="b"
label="Cluster Bottom"
c -> d
}
}digraph {
t [labelloc=t]
c [labelloc=c]
b [labelloc=b]
}- 节点
- 图表
- 集群
labeltarget
labelURL links in
类型: escString, 默认值: <none>
如果边具有URL或labelURL属性,该属性决定了浏览器使用哪个窗口来打开附加在标签上的URL。
设置 labeltarget=_graphviz 会在窗口不存在时打开一个新窗口,如果已存在则复用该窗口。
如果未定义,则使用target的值。
- 边
注意: 仅适用于map, svg。
labeltooltip
类型: escString, 默认值: ""
- 边
labelURL
labelURL is the link used for the label of an edge
类型: escString, 默认值: ""
labelURL 会覆盖为该边定义的任何 URL。
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
landscape
类型: bool, 默认值: false
等同于
rotate=90 或 orientation=landscape。
digraph {
landscape=true
a -> b
}另请参阅:
Valid on:- 图表
layer
类型: layerRange, 默认值: ""
- 边
- 节点
- 集群
layerlistsep
layerRange into a list of ranges.
类型:string, 默认值:","
- 图表
在Graphviz代码库中搜索 "layerlistsep"
layers
类型:layerList, 默认值:""
然后图形会以单独的图层输出。只有属于当前输出图层的组件才会显示。
参见如何使用绘图层(叠加层)。
Valid on:- 图表
layerselect
类型: layerRange, 默认值: ""
- 图表
layersep
layers attribute into a list of layer names.
类型:string, 默认值:":\t "
- 图表
layout
类型: string, 默认值: ""
指定要使用的布局引擎名称,例如dot或neato。
通常情况下,图形应保持与布局类型无关。但在某些情况下,将所需的布局类型嵌入图形中可能会更加方便。
例如,一个包含来自布局的位置信息的图可能希望记录关联的布局引擎是什么。
该属性优先于-K标志或实际使用的命令名称。
- 图表
len
类型: double, 默认值: 1.0 (neato), 0.3 (fdp)
另请参阅:
Valid on:- 边
levels
类型:int, 默认值:INT_MAX, 最小值:0.0
- 图表
注意: sfdp 专用。
levelsgap
类型: double, 默认值: 0.0
指定在neato中使用mode="ipsep"或mode=hier时层级约束的严格程度。
较大的正值意味着更严格的约束,要求层级之间有更大的间隔。另一方面,负值会放宽约束,允许层级之间存在部分重叠。
Valid on:- 图表
注意: neato 专用。
lhead
类型: string, 默认值: ""
当 compound 为 true 时,如果定义了 lhead 并且其值为包含实际头节点的集群名称,则该边会被裁剪至集群边界。
digraph {
compound=true;
subgraph cluster_a {
label="Cluster A";
node1; node3; node5; node7;
}
subgraph cluster_b {
label="Cluster B";
node2; node4; node6; node8;
}
node1 -> node2 [label="1"];
node3 -> node4 [label="2" ltail="cluster_a"];
node5 -> node6 [label="3" lhead="cluster_b"];
node7 -> node8 [label="4" ltail="cluster_a" lhead="cluster_b"];
}参见 limitation。
Valid on:- 边
注意: dot 专用。
lheight
类型: double
Valid on:- 图表
- 集群
注意: 仅限写入。
linelength
类型: int, 默认值: 128, 最小值: 60
示例,其中将一个80个字符长的字符串("a " * 40)在打印为canonical output时被分成两行:
$ echo 'digraph G { linelength=60; N0 [label="a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a "]; }' | dot -Tcanon
digraph G {
graph [linelength=60];
node [label="\N"];
N0 [label="a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \
a a a a a a a a a a "];
}
当label达到给定大小时,文本会溢出。
尽管名为linelength,但这指的是属性字符串的长度,而非整行的长度(整行包含节点ID和属性键)。
- 图表
lp
类型: point
标签中心位置,以点为单位。
Valid on:- 边
- 图表
- 集群
注意: 仅限写入。
ltail
类型: string, 默认值: ""
当 compound=true 时,如果定义了 ltail 并且它是一个包含实际尾部节点的集群名称,则该边会被裁剪至该集群的边界。
digraph {
compound=true;
subgraph cluster_a {
label="Cluster A";
node1; node3; node5; node7;
}
subgraph cluster_b {
label="Cluster B";
node2; node4; node6; node8;
}
node1 -> node2 [label="1"];
node3 -> node4 [label="2" ltail="cluster_a"];
node5 -> node6 [label="3" lhead="cluster_b"];
node7 -> node8 [label="4" ltail="cluster_a" lhead="cluster_b"];
}参见 limitation。
Valid on:- 边
注意: dot 专用。
lwidth
类型: double
Valid on:- 图表
- 集群
注意: 仅限写入。
margin
类型: double | point, 默认值: <device-dependent>
如果边距是一个单独的双精度值,则左右边距都会被设置为相同的给定值。
请注意,边距(margin)并非绘图的一部分,而仅是绘图周围留出的空白区域。边距本质上相当于对绘图进行平移,就像在页面上居中绘图所需的那样。实际上边距内不会绘制任何内容。如需真正扩展绘图的背景区域,请参阅pad属性。
对于集群,margin指定了集群内节点与集群边界框之间的间距。默认情况下,这个值为8点。
对于节点,此属性指定节点标签周围保留的空间。默认情况下,该值为0.11,0.055。
graph {
"1.5x0.5" [shape=rect margin="1.5,0.5"] # in inches
"0.5x1.5" [shape=rect margin="0.5,1.5"] # in inches
"1.5x1.5" [shape=rect margin="1.5"] # in inches
}graph {
bgcolor=lightgray
margin=0 # in inches
subgraph cluster_one {
margin=8 # in points
a
b
}
subgraph cluster_two {
margin=16 # in points
c
d
}
}- 节点
- 集群
- 图表
maxiter
类型:int, 默认值:100 * # nodes (模式 == KK) , 200 (模式 == major) , 30 (模式 == sgd) , 600 (fdp)
- 图表
mclimit
类型: double, 默认值: 1.0
用于改变交叉最小化过程中使用的MinQuit(默认=8)和MaxIter(默认=24)参数的乘法比例因子。
这些对应于在退出前未改进的尝试次数以及每次传递中的最大迭代次数。
Valid on:- 图表
注意: dot 专用。
mindist
类型: double, 默认值: 1.0, 最小值: 0.0
- 图表
注意: circo 专用。
minlen
类型:int, 默认值:1, 最小值:0
另请参阅:
Valid on:- 边
注意: dot 专用。
mode
类型: string, 默认值: major
neato 支持以下模式:
mode="major":neato使用应力主化1。mode="KK":neato使用Kamada-Kawai2版本的梯度下降方法。KK对于小型图(节点数小于100)有时明显更快。 一个显著的缺点是KK可能会循环。mode="sgd":neato使用随机梯度下降3方法的变体。sgd的优势是比前两种方法收敛更快且更可靠, 而sgd的缺点是它以固定迭代次数运行, 在某些图中可能需要更大的maxiter值。
neato中有两种实验模式:
mode="hier",它添加了一个类似于dot中使用的布局的自顶向下方向性,以及mode="ipsep",允许图形指定节点之间的最小垂直和水平距离。 (参见sep属性。)
-
Gansner, E.R., Koren, Y., North, S. (2005). 基于应力优化的图绘制方法. 收录于: Pach, J. (编) 图绘制. GD 2004. 计算机科学讲义, 卷3383. 施普林格, 柏林, 海德堡. ↩︎
-
Tomihisa Kamada, Satoru Kawai, 一种绘制通用无向图的算法, 信息处理快报, 第31卷, 第1期, 1989年, 第7-15页. ↩︎
-
J. X. Zheng, S. Pawar and D. F. M. Goodman, "Graph Drawing by Stochastic Gradient Descent," in IEEE Transactions on Visualization and Computer Graphics, vol. 25, no. 9, pp. 2738-2748, 1 Sept. 2019, doi: 10.1109/TVCG.2018.2859997. ↩︎
- 图表
注意: neato 专用。
model
类型: string, 默认值: shortpath
距离矩阵指定了每对节点之间的理想距离。
neato尝试找到一个最能实现这些距离的布局。默认情况下,它使用最短路径的长度,其中每条边的长度由其len属性给出。
- 如果
model="circuit",neato 会使用电路电阻模型来计算距离。这往往会突出显示集群。 - 如果
model="subset",neato 使用子集模型。该模型将边长度设置为端点中恰好一个端点的邻居节点数量,然后计算最短路径。这有助于分离高度数的节点。
为了更精确地控制距离,可以使用model=mds。在这种情况下,边的len将被用作其顶点之间的理想距离。
最短路径计算仅用于未被边连接的节点对。因此,通过提供一个完整的图,输入可以指定所有相关距离。
Valid on:- 图表
注意: neato 专用。
newrank
类型: bool, 默认值: false
dot中的原始排名算法对集群采用递归处理。这种方式可以减少层级数量并生成更紧凑的布局,但有时会导致头节点被放置在比尾节点更高的层级上。该算法还假设节点不会受到多个独立且互斥的子图约束。例如,一个节点不能同时存在于集群中,又与集群外的节点受到rank=same的约束。
这使得节点可以受到多重约束。层级约束通常会优先于边约束。
Valid on:- 图表
注意: dot 专用。
nodesep
dot, nodesep specifies the minimum space between two adjacent nodes in the same rank, in inches
类型: double, 默认值: 0.25, 最小值: 0.02
对于其他布局,nodesep会影响单个节点上循环之间的间距,或一对节点之间的多重边距。
digraph {
nodesep=0.1;
node1; node2; node3;
}digraph {
nodesep=0.5;
node1; node2; node3;
}- 图表
nojustify
类型: bool, 默认值: false
默认情况下,多行标签的对齐方式会在最合理的最大上下文中完成。因此,在多边形节点的标签中,左对齐的行将与节点的左侧对齐(根据指定的margin进行偏移)。在记录节点中,左对齐的行将与包含字段列的左侧对齐。如果nojustify=true,多行标签将在其自身的上下文中对齐。
例如,如果设置了nojustify,第一行标签较长,而第二行较短且左对齐,则第二行将与第一行最左侧的字符对齐,无论节点大小如何。
请参阅这个包含 \l (左对齐) 转义字符串的示例:
digraph G {
node [width=3 shape=box]
a [nojustify=false label="The first line is longer\nnojustify=false\l"]
b [nojustify=true label="The first line is longer\nnojustify=true\l"]
a -> b
}digraph G{
c [nojustify=false shape=record label="{Records Example - Long Line\n | Title - Shorter Line\nnojustify=false\l}"]
d [nojustify=true shape=record label="{Records Example - Long Line\n | Title - Shorter Line\nnojustify=true\l}"]
c -> d
}- 图表
- 集群
- 节点
- 边
normalize
这样第一个点位于原点,然后旋转布局使得第一条边的角度由normalize的值以度数为单位指定。
如果normalize不是数字,则会被评估为布尔值,其中true对应0度。
注意: 由于属性首先会被当作数字进行计算,0 和 1
不能用于表示 false 和 true。
- 图表
注意: neato, fdp, sfdp, twopi, circo 仅限这些布局引擎。
notranslate
类型: bool, 默认值: false
默认情况下,最终布局会被平移,使包围框的左下角位于原点。
如果某些节点被固定或用户运行neato -n,这可能会很烦人。
为避免此翻译,请设置notranslate=true。
- 图表
注意: neato 专用。
nslimit
类型: double
nslimit 用于计算 node x coordinates。
如果已定义,# iterations = nslimit * # nodes;否则,# iterations = INT_MAX。
- 图表
注意: dot 专用。
nslimit1
类型: double
nslimit1 用于节点排名。
如果已定义,# iterations = nslimit * # nodes;否则,# iterations = INT_MAX。
- 图表
注意: dot 专用。
oneblock
类型: bool, 默认值: false
观察两个渲染同一图形的示例:
digraph G {
layout="circo"
oneblock=false
N0 -> N1
N1 -> N2
N2 -> N3
N3 -> N4
N4 -> N0
N4 -> N5
N5 -> N6
N6 -> N7
N7 -> N8
N8 -> N5
}digraph G {
layout="circo"
oneblock=true
N0 -> N1
N1 -> N2
N2 -> N3
N3 -> N4
N4 -> N0
N4 -> N5
N5 -> N6
N6 -> N7
N7 -> N8
N8 -> N5
}- 图表
注意: circo 专用。
ordering
类型: string, 默认值: ""
如果 ordering="out",则节点的出边(即以该节点作为尾节点的边)必须按照输入中定义的相同顺序从左到右排列。
如果 ordering="in",则节点的入边必须按照输入中定义的顺序从左到右排列。
如果定义为图或子图的属性,该值将应用于图或子图中的所有节点。
请注意,graph属性优先于node属性。
Valid on:- 图表
- 节点
注意: dot 专用。
orientation
类型: double | string, 默认值: 0.0, "", 最小值: -360.0
当用于节点时:角度(以度为单位),用于旋转多边形节点形状。对于任意边数的多边形,0度旋转会使底部保持水平。
当用于图表时:如果为"[lL]*",则将图表方向设置为横向。
仅在未定义rotate时使用。
digraph {
layout=neato # Render in a circular layout
node [shape=house] # Make all nodes have 'house' shape
0 [orientation=0]
45 [orientation=45]
90 [orientation=90]
135 [orientation=135]
180 [orientation=180]
225 [orientation=225]
270 [orientation=270]
315 [orientation=315]
0 -> 45 -> 90 -> 135 -> 180 -> 225 -> 270 -> 315 -> 0
}digraph {
orientation=L
a -> b
}另请参阅:
Valid on:- 节点
- 图表
outputorder
类型: outputMode, 默认值: breadthfirst
- 图表
overlap
节点首先通过sep属性进行放大。如果值为true,则保留重叠部分。如果值为"scale",则通过统一缩放x和y轴来消除重叠。如果值转换为"false"且可用时,将使用基于邻近图算法的Prism来消除节点重叠。也可以通过显式调用overlap=prism来使用此技术。该技术从一个小幅放大开始,由overlap_scaling属性控制,可以消除大部分重叠。prism选项还接受一个可选的非负整数后缀,用于控制重叠消除的尝试次数。默认情况下,overlap="prism"等同于overlap="prism1000"。设置overlap="prism0"将仅运行缩放阶段。
如果Prism不可用,或者Graphviz版本早于2.28,
"overlap=false"会使用基于Voronoi的技术。您始终可以通过"overlap=voronoi"显式调用此技术。
如果 overlap="scalexy",x和y轴会分别进行缩放以消除重叠。
如果 overlap="compress",布局将被尽可能缩小而不引入任何重叠,显然前提是初始状态下不存在重叠。
注意: overlap 其余允许的值对应的算法目前可能会产生不佳的长宽比。此外,我们不推荐使用 "ortho*" 和 "portho*"。
如果值为"vpsc",重叠移除将通过二次优化来完成,以在消除节点重叠的同时最小化节点位移。
如果值为"orthoxy"或"orthoyx",则通过优化两个约束问题来移动重叠部分,一个针对x轴,一个针对y轴。后缀表示首先处理哪个轴。如果值为"ortho",该技术与"orthoxy"类似,但使用启发式方法来减少两次处理之间的偏差。如果值为"ortho_yx",则该技术与"ortho"相同,只是x和y的角色互换。值"portho"、"porthoxy"、"porthoxy"和"portho_yx"与前四个类似,但仅强制执行伪正交排序。
如果布局是由neato使用mode="ipsep"完成的,那么可以使用overlap=ipsep。在这种情况下,重叠消除约束会被整合到布局算法本身中。注意:目前这仅支持单层聚类。
除了fdp和sfdp之外,其他布局默认采用overlap="true"。
Fdp首先会使用内置的力导向技术进行多次尝试来消除重叠。因此,fdp接受带有整数前缀加冒号的overlap参数,用于指定尝试次数。如果没有前缀,则不会执行初始尝试。如果冒号后没有内容,则不会尝试上述任何方法。默认情况下,fdp使用overlap="9:prism"。请注意,overlap="true"、overlap="0:true"和overlap="0:"都会关闭所有重叠消除功能。
默认情况下,sfdp 使用 overlap="prism0"。
除了Voronoi和棱柱方法外,所有这些变换都保留了原始布局的正交顺序。也就是说,如果两个节点的x坐标最初相同,它们将保持不变;如果一个节点的x坐标最初小于另一个节点的x坐标,这种关系在变换后的布局中仍然成立。类似的性质也适用于y坐标。对于"porth*"情况,这一点并不完全正确。在这些情况下,正交顺序仅在通过边相关的节点之间保留。
- 图表
注意: fdp, neato, sfdp, circo, twopi 仅支持这些布局引擎。
overlap_scaling
类型: double, 默认值: -4, 最小值: -1e+10
当overlap=prism时,布局会按此比例因子进行缩放,从而显著减少节点重叠,并使节点重叠消除过程更快且能更好地保持图形形状。
-
如果
overlap_scaling为负值,布局将按-1*overlap_scaling乘以平均标签大小进行缩放。 -
如果
overlap_scaling为正数,则布局会按overlap_scaling进行缩放。 -
如果
overlap_scaling为零,则不进行缩放。
- 图表
注意: prism, neato, sfdp, fdp, circo, twopi 仅支持这些布局引擎。
在Graphviz代码库中搜索"overlap_scaling"
overlap_shrink
类型: bool, 默认值: true
- 图表
注意: prism 专用。
在Graphviz代码库中搜索 "overlap_shrink"
pack
如果pack有一个整数值,这将用作每个部件周围边距的大小,单位为points;否则,将使用默认边距8。
如果pack被解释为false,则整个图形将一起布局。
打包的粒度和方法受packmode属性影响。
对于总是进行打包的布局,例如twopi,pack属性仅用于设置边距。
如果pack的值为true(不区分大小写)或非负整数,则pack被视为true。
- 图表
packmode
类型: packMode, 默认值: node
(参见 packMode)。请注意,定义 packmode 将自动启用打包功能,就像设置了 pack=true 一样。
- 图表
pad
类型: double | point, 默认值: 0.0555 (4 点)
如果pad是一个单独的双精度值,那么x和y方向的填充值都将被设置为该给定值。这个区域是绘图的一部分,如果适用的话,将会用背景色填充。
通常出于美观考虑会使用一个小的pad,特别是在使用背景颜色时,以避免节点和边缘紧贴绘制区域的边界。
- 图表
page
如果只提供一个值,则该值将同时用于宽度和高度。
如果设置了page且其值小于布局尺寸,系统会在布局上叠加一个指定页面大小的矩形页面阵列,所有页面的左下角原点对齐,从而将布局分割为多个页面。随后这些页面会按照pagedir顺序逐一生成。
目前,page仅适用于PostScript输出。对于其他类型的输出,
请使用其他工具将输出拆分为多个输出文件,
或使用viewport来生成多个文件。
- 图表
pagedir
类型: pagedir, 默认值: BL
仅当设置了page且适用时使用。
仅限于8种行优先或列优先顺序之一。
Valid on:- 图表
pencolor
类型: color, 默认值: black
如果未定义pencolor,则使用color。
如果未定义bgcolor,则使用默认值。
请注意,如果定义了根图的属性,集群会继承这些属性。因此,如果根图定义了pencolor,这将覆盖为集群设置的color或bgcolor属性。
- 集群
penwidth
类型: double, 默认值: 1.0, 最小值: 0.0
包括边和簇的边界。
penwidth 值会被子集群继承,并且对文本没有影响。
在2008年1月31日之前,penwidth=W的效果是通过将setlinewidth(W)作为style规范的一部分来实现的。
如果同时设置了这两个属性,将使用penwidth。
- 集群
- 节点
- 边
peripheries
类型: int, 默认值: <shape default> (节点), 1 (集群), 最小值: 0
请注意,用户自定义形状被视为一种盒子形状,因此默认的边框值为1,用户自定义形状将在一个边界矩形中绘制。设置peripheries=0将关闭此功能。
peripheries=1 是集群的最大值。
- 节点
- 集群
pin
类型: bool, 默认值: false
如果为true且节点在输入时具有pos属性,neato或fdp会阻止节点从输入位置移动。此属性也可以在pos属性本身中指定(参见point类型)。
注意:由于实现上的一个特性,在2014年2月27日之前,最终坐标会被平移到原点。因此,如果您查看(x)dot或plain格式给出的输出坐标,固定节点的输出坐标将与输入时的坐标不同。如果这一点很重要,一个简单的解决方法是保持固定节点的坐标不变。新旧坐标之间的向量差即为平移量,然后可以从所有相关坐标中减去这个平移量。
2014年2月27日后,在neato中可以通过设置notranslate=true来避免此转换。然而,如果图形指定了节点重叠移除或更改了ratio宽高比,节点坐标仍可能发生变化。
- 节点
pos
类型: point | splineType
对于节点,位置表示节点的中心。输出时,坐标单位为points。
在neato和fdp中,pos可用于设置节点的初始位置。默认情况下,坐标单位被假定为英寸。但通过-s命令行标志可以指定不同的单位。由于输出坐标以点为单位,将Graphviz程序布局好的图形输出重新输入到neato或fdp时,几乎总是需要使用-s标志。
当-n命令行标志与neato一起使用时,假设位置已由某个布局程序设置,因此以点为单位。因此,neato -n可以正确接受输入而无需-s标志,并且实际上会忽略任何此类标志。
- 边
- 节点
quadtree
类型: quadType | bool, 默认值: normal
quadtree=true别名quadtree=normalquadtree=false别名quadtree=nonequadtree=2别名quadtree=fast
- 图表
注意: sfdp 专用。
quantum
quantum > 0.0, node label dimensions will be rounded to integral multiples of the quantum
类型: double, 默认值: 0.0, 最小值: 0.0
- 图表
rank
类型: rankType
- 如果
rank="same",所有节点将被放置在同一层级。 - 如果
rank="min",所有节点将被放置在最小层级上。 - 如果
rank="source",所有节点都会被放置在最小层级上,且最小层级上的节点仅属于具有rank="source"或rank="min"的子图。
类似的标准也适用于 rank="max" 和 rank="sink"。
(注意:最小层级位于最上方或最左侧,最大层级位于最下方或最右侧。)
如需了解更多信息,请查看Stack Overflow上的这个回答
Valid on:- 子图
注意: dot 专用。
rankdir
类型: rankdir, 默认值: TB
例如,如果 rankdir="LR",且不存在循环的情况下,边 T -> H; 会从左向右延伸。默认情况下,graphviz 的布局是从上至下的。
该属性还会影响记录节点的解释方式。详情请参阅record shapes。
digraph {
rankdir="TB"
a -> b -> c;
}digraph {
rankdir="BT"
a -> b -> c;
}digraph {
rankdir="LR"
a -> b -> c;
}digraph {
rankdir="RL"
a -> b -> c;
}- 图表
注意: dot 专用。
ranksep
类型: double | doubleList, 默认值: 0.5 (dot) , 1.0 (twopi) , 最小值: 0.02
在dot中,设置所需的层级间距,单位为英寸。
这是同一层级中节点底部与下一层级节点顶部之间的最小垂直距离。如果值包含equally,则表示所有层级的中心点将保持等距分布。请注意这两种设置可以同时使用,例如ranksep="1.2 equally"。
在twopi中,此属性指定同心圆的径向间距。
对于twopi,ranksep也可以是一个双精度浮点数列表。第一个双精度数指定
内圆的半径;第二个双精度数指定从第一个圆到第二个圆的
半径增量;以此类推。如果圆的数目超过给定的数值,
最后一个数值将作为剩余圆的增量。
- 图表
ratio
请注意,这是在强制执行size属性约束之前进行调整的。
此外,计算通常会忽略节点大小,因此最终绘制的尺寸可能仅近似于预期效果。
如果ratio是数值类型,ratio将被视为期望的宽高比。
然后,如果实际宽高比小于期望比例,
绘图高度将被放大以达到期望比例;如果实际比例大于期望比例,
绘图宽度将被放大。
如果设置ratio="fill"且指定了size属性,节点位置会分别在x轴和y轴方向进行缩放,使得最终绘图完全填满指定尺寸。当size的宽度和高度值都超过绘图原始尺寸时,所有节点的坐标值将按比例放大。但若任一维度小于绘图对应维度,则会按比例放大其中一个维度,使最终绘图保持与size指定的相同宽高比。
随后渲染时,布局会在两个维度上按统一比例缩小以适应给定的size,这可能导致节点和文本也随之缩小。虽然这可能不符合用户预期,但避免了如何以可接受方式重新定位节点来缩小绘图尺寸这一难题。
如果设置ratio="compress"且指定了size属性,graphviz会尝试压缩初始布局以适应给定尺寸。这样可以实现更紧凑的节点排列,但会降低平衡性和对称性。此功能仅在graphviz中有效。
如果 ratio="expand",设置了 size 属性,并且图形的宽度和高度都小于 size 中的值时,节点位置会统一缩放,直到至少一个维度完全匹配 size。请注意,这与将 size 用作期望尺寸不同,因为此处的绘图会在生成边之前进行扩展,且所有节点和文本尺寸保持不变。
如果ratio="auto",设置了page属性且图形无法在单页上绘制,则size会被设置为一个"理想"值。
具体来说,给定维度上的大小将是该维度页面尺寸的最小整数倍,且至少为当前尺寸的一半。然后两个维度会独立缩放到新尺寸。此功能仅在dot中有效。
- 图表
rects
类型: rect
Valid on:- 节点
注意: 仅限写入。
regular
类型: bool, 默认值: false
如果为true,多边形的顶点将位于一个圆上,该圆的中心是节点的中心。
digraph {
"pentagon1" [shape="pentagon"];
"pentagon2" [shape="pentagon" regular=true]
"hexagon1" [shape="hexagon"];
"hexagon2" [shape="hexagon" regular=true];
}- 节点
remincross
类型: bool, 默认值: true
- 图表
注意: dot 专用。
repulsiveforce
类型: double, 默认值: 1.0, 最小值: 0.0
力导向模型。大于1的值会减少扭曲效果,但代价是降低聚类程度。
- 图表
注意: sfdp 专用。
在Graphviz代码库中搜索"repulsiveforce"
resolution
dpi.
类型: double, 默认值: 96.0, 最小值: 0.0
- 图表
注意: 位图输出,仅支持svg格式。
root
类型: string | bool, 默认值: <none> (图形) , false (节点)
布局的中心将是生成生成树的根节点。
- 作为图属性,这给出了节点的名称。
- 作为节点属性,它指定该节点应被用作中心节点。
在twopi中,root实际上会成为中心节点。在circo中,包含该节点的区块将在其连接组件的绘制中处于中心位置。如果未定义,twopi将选择一个最中心的节点,而circo将随机选择一个节点。
如果根属性被定义为空字符串,twopi会将其重置为被选作根节点的节点名称。
对于twopi布局,可能存在多个根节点,通常每个组件对应一个根节点。如果在一个组件中有多个节点被标记为root,twopi将自动选择其中一个作为根节点。
- 图表
- 节点
rotate
rotate=90, sets drawing orientation to landscape
类型: int, 默认值: 0
digraph {
rotate=90
a -> b
}另请参阅:
Valid on:- 图表
rotation
类型: double, 默认值: 0
- 图表
注意: sfdp 专用。
samehead
samehead value are aimed at the same point on the head
类型: string, 默认值: ""
这对循环没有影响。
在Graphviz 8.0.1版本之前,每个节点最多只能有5个不同的samehead值。
参见 limitation。
另请参阅 sametail。
- 边
注意: dot 专用。
sametail
sametail value are aimed at the same point on the tail.
类型: string, 默认值: ""
这对循环没有影响。
在Graphviz 8.0.1之前,每个节点最多可以有5个唯一的sametail值。
参见 limitation。
另请参阅 samehead。
- 边
注意: dot 专用。
samplepoints
类型: int, 默认值: 8 (输出), 20 (重叠和图像映射)
如果输入图定义了vertices属性,并且输出为dot或xdot时使用。
在neato中调整布局以避免节点重叠时,以及在图像映射中,它扮演着相同的角色。
- 节点
scale
如果只给出一个数字,则该数字会同时缩放宽度和高度。
Valid on:- 图表
searchsize
类型: int, 默认值: 30
- 图表
注意: dot 专用。
sep
类型: addDouble | addPoint, 默认值: +4
这保证了节点之间的最小非零距离。
如果属性以加号'+'开头,则表示指定了一个附加边距。也就是说,"+w,h"会使节点的边界框在左右两侧增加w点,在顶部和底部增加h点。
没有加号时,节点在x坐标方向上按1 + w缩放,在y坐标方向上按1 + h缩放。
如果只给出一个数字,则该数字将用于两个维度。
如果未设置但定义了esep,则sep值将被设置为esep值除以0.8。如果esep未设置,则使用默认值。
graph {
layout="fdp"
sep="0"
A -- B
B -- C
C -- D
D -- A
}graph {
layout="fdp"
sep="3"
A -- B
B -- C
C -- D
D -- A
}- 图表
注意: fdp, neato, sfdp, osage, circo, twopi 仅限这些布局引擎。
shape
类型: shape, 默认值: ellipse
digraph {
"pentagon" [shape="pentagon"];
"hexagon" [shape="hexagon"];
}- 节点
shapefile
类型: string, 默认值: ""
(已弃用)。
设置节点的shape="box"。形状文件中的图像必须是矩形。支持的图像格式以及文件使用的精确语义取决于output format。更多详情,请参阅Image Formats和External PostScript files。
这种用法有一个例外:如果shape="epsf",
shapefile会提供一个包含节点PostScript定义的文件名。定义的图形必须包含节点的所有内容,
包括任何所需的边界。更多详细信息,请参阅External PostScript files。
仅支持本地资源的路径。如需使用远程资源的URL,请参阅dot_url_resolve.py脚本。
- 节点
showboxes
类型:int, 默认值:0, 最小值:0
在routesplines开始时,如果showboxes=1则在PostScript中打印引导框,如果showboxes=2则在结束时打印。(仅限调试模式,TB模式!)
- 边
- 节点
- 图表
注意: dot 专用。
sides
shape=polygon
类型: int, 默认值: 4, 最小值: 0
graph {
Triangle [shape=polygon sides=3]
Rectangle [shape=polygon sides=4]
Pentagon [shape=polygon sides=5]
Hexagon [shape=polygon sides=6]
}- 节点
size
如果只给出一个数字,则该数字将同时用作宽度和高度。
如果已定义且绘图大于给定尺寸,则绘图将按比例统一缩小,以适应给定尺寸。
如果size以感叹号"!"结尾,那么size将被视为所需的最小尺寸。在这种情况下,如果绘图的两个尺寸都小于size,则绘图将均匀放大,直到至少一个尺寸等于其在size中的尺寸。
size和ratio属性之间存在一定的交互作用。
- 图表
skew
shape=polygon
类型: double, 默认值: 0.0, 最小值: -100.0
正值使多边形顶部向右倾斜;负值使多边形顶部向左倾斜。
另请参阅 distortion。
graph {
SkewLeft [shape=polygon sides=4 skew=-.5]
SkewRight [shape=polygon sides=4 skew=.5]
}- 节点
smoothing
类型: smoothType, 默认值: "none"
- 图表
注意: sfdp 专用。
sortv
packmode packing.
类型:int, 默认值:0, 最小值:0
如果packmode表示数组打包,sortv则指定组件间的插入顺序,数值较小的组件会优先插入。
- 图表
- 集群
- 节点
splines
如果 splines=true,边将以绕过节点的样条曲线绘制;如果
splines=false,边将以直线段绘制。如果 splines=none 或
splines="",则完全不绘制任何边。
(2007年3月1日) splines=line 和 splines=spline 可以分别作为 splines=false 和 splines=true 的同义词使用。
此外,splines=polyline指定边应绘制为折线。
(2010年9月28日) splines=ortho 指定边应作为轴对齐线段的多段线进行路由。目前,该路由不支持端口处理,在dot中也不支持边标签。
(2012年9月25日) splines=curved 指定边应绘制为曲线弧。
![]() |
![]() |
| splines=none splines="" |
splines=line splines=false |
![]() |
![]() |
| splines=polyline | splines=curved |
![]() |
![]() |
| splines=ortho | splines=spline splines=true |
默认情况下,splines参数未设置。其解释方式取决于布局引擎。对于dot布局,默认将边绘制为样条曲线。对于所有其他布局,默认将边绘制为直线段。
请注意,对于后面这些布局,如果splines="true",这要求节点不能重叠(参见overlap)。
如果使用fdp进行布局且splines="compound",那么绘制边时会避开簇和节点。
- 图表
start
类型: startType, 默认值: ""
如果未设置,节点会随机放置在一个单位正方形内,并且始终使用相同的种子作为随机数生成器,因此初始布局是可重复的。
以下示例具有相同的图形,但由于它们的start值不同,渲染效果也不同:
graph {
layout="fdp"
start=1
A -- B; B -- C; C -- D; D -- A
}graph {
layout="fdp"
start=2
A -- B; B -- C; C -- D; D -- A
}- 图表
style
类型: style, 默认值: ""
对于集群子图,如果设置style="filled",则集群框的背景会被填充。
如果已为组件设置了默认样式属性,单个组件可以使用style=""来恢复为正常默认值。例如,如果图表中有
digraph {
edge [style="invis"]
a -> b
}将所有边设为不可见时,b->c边可以通过以下方式覆盖此设置:
digraph {
edge [style="invis"]
a -> b
b -> c [style=""]
}当然,组件也可以显式地将其style属性设置为所需的值。
- 边
- 节点
- 集群
- 图表
stylesheet
类型: string, 默认值: ""
结合class使用CSS选择器来设置元素样式。
另请参阅:
Valid on:- 图表
注意: svg 仅限。
tail_lp
类型: point
该位置表示标签的中心点。
Valid on:- 边
注意: 仅限写入。
tailclip
类型: bool, 默认值: true
否则,边的终点会指向节点的中心,或者如果适用的话,指向端口的中心。
Valid on:- 边
tailhref
tailURL.
类型: escString, 默认值: ""
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
taillabel
类型: lblString, 默认值: ""
参见 limitation。
Valid on:- 边
tailport
类型: portPos, 默认值: center
参见 limitation。
Valid on:- 边
tailtarget
tailURL link
类型: escString, 默认值: <none>
如果边具有tailURL,tailtarget将决定浏览器使用哪个窗口来打开该URL。
设置 tailtarget=_graphviz 如果窗口不存在则会打开一个新窗口,如果已存在则会复用该窗口。
如果未定义,则使用target的值。
- 边
注意: 仅适用于map, svg。
tailtooltip
类型: escString, 默认值: ""
仅在边具有tailURL属性时使用。
- 边
tailURL
tailURL is output as part of the tail label of the edge
类型: escString, 默认值: ""
此外,这个值会在接近尾节点时使用,覆盖任何URL值。
参见 limitation。
另请参阅:
Valid on:- 边
注意: 仅适用于map, svg。
target
URL, this attribute determines which window of the browser is used for the URL.
类型: escString | string, 默认值: <none>
参见 W3C文档。
Valid on:- 边
- 节点
- 图表
- 集群
注意: 仅适用于map, svg。
TBbalance
类型: string, 默认值: ''
有效选项:
尽管名称是TBbalance("上下平衡"),但它也适用于左右排列的情况,例如rankdir=LR。
示例:
digraph {
layout="dot"
{ rank="min"; "min" }
{ rank="max"; "max" }
"min" -> "middle" -> "max"
"Floater 1"
"Floater 2"
}digraph {
layout="dot"
TBbalance="min"
{ rank="min"; "min" }
{ rank="max"; "max" }
"min" -> "middle" -> "max"
"Floater 1"
"Floater 2"
}digraph {
layout="dot"
TBbalance="max"
{ rank="min"; "min" }
{ rank="max"; "max" }
"min" -> "middle" -> "max"
"Floater 1"
"Floater 2"
}- 图表
注意: dot 专用。
tooltip
类型: escString, 默认值: ""
如果未设置tooltip,Graphviz将使用对象的label(如果已定义)。
请注意,如果label是记录规范或类似HTML的标签,生成的工具提示可能没有帮助。在这种情况下,如果要生成工具提示,用户应显式设置tooltip属性。
digraph {
label="Graph Label"
tooltip="Graph Tooltip"
subgraph cluster_a {
label="Cluster Label"
tooltip="Cluster Tooltip"
Node1 [tooltip="Node1 Tooltip"]
Node1 -> Node2 [label="Edge" tooltip="Edge Tooltip"]
}
}另请参阅:
Valid on:- 节点
- 边
- 集群
- 图表
truecolor
类型:bool
调色板。
如果未设置truecolor,则不会使用truecolor
除非图中某些节点具有shapefile属性。
在可能的情况下,输出模型将使用输入模型。
使用调色板可以在创建位图时减少内存使用量,并生成更小的输出文件。
通常,只有在图形使用超过256种颜色时,才需要指定truecolor模型。
然而,如果在调色板中使用bgcolor=transparent,
字体抗锯齿可能会在字符周围显示为模糊的白色区域。
使用truecolor=true可以避免这个问题。
- 图表
注意: 仅支持位图输出。
URL
类型: escString, 默认值: <none>
目前,用于ps2、cmap、i*map和svg格式。
对于所有这些格式,可以将URL附加到节点、边和
集群。URL属性也可以附加到ps2、
cmap和i*map格式的根图上。在前者中作为相对URL的基础URL,
在后者中作为默认的图像映射文件。
对于svg、cmapx和imap输出格式,节点的活动区域是其可见图像。
例如,一个未填充且没有绘制边界的节点将仅在其标签上处于活动状态。
对于其他输出格式,活动区域是其边界框。
集群的活动区域是其边界框。
对于边而言,活动区域是边与头尾节点接触处的小圆圈。此外,对于svg、cmapx和imap格式,活动区域还包括一个近似边的细多边形。圆圈可能与相关节点重叠,此时边的URL优先。
如果边有标签,该标签也将处于活动状态。
最后,如果边有头部或尾部标签,这些标签也将处于活动状态。
对于边(edges),属性headURL、
tailURL、labelURL和
edgeURL允许控制边的各个部分。
如果两条边的活动区域重叠,则未指定哪个区域占主导地位。
另请参阅:
graph {
label="Vincent van Gogh Paintings"
URL="https://en.wikipedia.org/wiki/Vincent_van_Gogh"
subgraph cluster_self_portraits {
URL="https://en.wikipedia.org/wiki/Portraits_of_Vincent_van_Gogh"
label="Self-portraits"
"Self-Portrait with Grey Felt Hat" [URL="https://www.vangoghmuseum.nl/en/collection/s0016V1962"]
"Self-Portrait as a Painter" [URL="https://www.vangoghmuseum.nl/en/collection/s0022V1962"]
}
subgraph cluster_flowers {
URL="https://en.wikipedia.org/wiki/Sunflowers_(Van_Gogh_series)"
label="Flowers"
"Sunflowers" [URL="https://www.nationalgallery.org.uk/paintings/vincent-van-gogh-sunflowers"]
"Almond Blossom" [URL="https://www.vangoghmuseum.nl/en/collection/s0176V1962"]
}
}- 边
- 节点
- 图表
- 集群
注意: 仅适用于map、postscript、svg格式。
vertices
类型:pointList
如果节点是多边形的,并且输出是dot或xdot时使用。
如果节点是椭圆或圆形,samplepoints属性会影响输出。
- 节点
注意: 仅限写入。
viewport
类型: viewPort, 默认值: ""
viewport 会覆盖任何 size 属性。视口的宽度和高度精确指定了输出的最终尺寸。
- 图表
voro_margin
类型: double, 默认值: 0.05, 最小值: 0.0
用于放大绘制的比例因子,以便为Voronoi技术中的扩展留出边距。
dim' = (1+2*margin)*dim。
- 图表
注意: neato, fdp, sfdp, twopi, circo 仅限这些布局引擎。
weight
类型: int | double, 默认值: 1, 最小值: 0(dot,twopi), 1(neato,fdp)
在dot中,权重值越大,边就会越短、越直且越垂直。
对于twopi,weight=0表示在从根节点构建生成树时不应使用该边。
对于其他布局,较大的权重会促使布局使边长更接近len属性指定的长度。
dot中的权重必须是整数。
digraph {
root -> a
root -> b [weight=2]
root -> c [weight=3]
}- 边
width
类型: double, 默认值: 0.75, 最小值: 0.01
这被视为节点的初始最小宽度。如果
fixedsize为真,这将是节点的最终宽度。否则,如果节点标签需要更多宽度来适应,节点的宽度将增加以包含标签。
如果输出格式是dot,那么给width的值将是最终值。
如果节点形状是规则的,宽度和高度将被设置为相同:
- 如果明确设置了宽度或高度,则使用该值。
- 如果明确设置了宽度或高度,则使用两者中的最大值。
- 如果两者都没有明确设置,则使用两个默认值中的较小值。
digraph {
"d" # default
"1in" [width=1]
"2in" [width=2]
}- 节点
xdotversion
xdot used in output类型: string
仅用于 xdot 输出。
如果未设置,graphviz 会将该属性设置为用于输出的 xdot 版本。
- 图表
注意: xdot 专用。
xlabel
类型: lblString, 默认值: ""
- 对于节点,标签将放置在节点外部但靠近它的位置。
- 对于边(edges),标签(label)会被放置在边的中心附近。这在dot中很有用,可以避免偶尔因使用边标签而导致布局变形的问题。
- 对于其他布局,xlabel属性可视为
label属性的同义词。
这些标签在所有节点和边放置完毕后添加。
标签将被放置以避免与任何节点或其他标签重叠。这意味着可能无法放置所有标签。若要强制放置所有标签,请设置forcelabels=true。
digraph {
"⚡" [xlabel="Sparks"]
"🔥" [xlabel="Fires"]
"⚡"->"🔥" [xlabel="Sometimes" label="Cause"]
}- 边
- 节点
xlp
类型: point
该位置表示标签的中心点。
Valid on:- 节点
- 边
注意: 仅限写入。
z
类型: double, 默认值: 0.0, 最小值: -MAXFLOAT, -1000
已弃用: 请使用 pos 属性,配合 dimen 和/或 dim 来指定尺寸。
如果图形设置了
dim为3(或更高),当节点的pos属性也被定义时,neato将使用节点的z值作为其初始位置的z坐标。
即使在输入中没有指定z值,为了在输出时获得z值,也必须为节点声明一个z属性,例如使用node[z=""]。因此,设置dim=3但不声明z会导致neato -Tvrml在3D空间中布局图形,但在渲染时将布局投影到xy平面上。如果声明了z属性,最终的渲染将是3D的。
- 节点





