GraphViz 真的不难学。这类图的基本语言非常简单。我只花了一些时间从那个 pdf 复制(或多或少)第一个例子,它的好处是,由于它很简单,很容易从其他数据源按程序生成图表。
Digraph fig1 {
rankdir = LR; //order things from left to right
//define alpha and beta as existing
α [shape=circle];
β [shape=circle];
//not strictly nescessary but helps if you want to
//assign them specific shapes or colours
subgraph cluster_M //names beginning with "cluster" get a box drawn, an odd hack
{
label = "M"
θ [shape=circle];
subgraph cluster_N
{
label = "N"
z [shape=circle];
w [shape=circle, style=filled]
z->w; //quite literally z points at w
}
θ -> z;
}
α -> θ;
β -> w;
}
使用 dot -Tpng input.txt -o graph.png 编译,它看起来像这样。如果在气泡下方放置标签很重要,您可以使用额外的几行来做到这一点,类似地,如果节点的特定位置很重要,您也可以调整它。实际上,如果您不指定图像格式,则 dot 的默认行为是输出一个版本的输入文件,其中包含每个元素位置的坐标。
