导入.dot文件作为子图 [英] Importing .dot file as subgraph
问题描述
是否存在-通过语言功能或通过前置处理程序-是否可能将外部.dot文件作为子图包含到另一个文件中?
Is there -- either via a language feature or via a preporcessor -- a possiblity to include external .dot files as subgraphs into another one?
我正在处理一个相对较大的图,尽管它是手动维护的,而不是生成的.
I am working on a relatively big graph, though manually maintained, not generated.
可以方便地定义一些
subgraph01.dot
:
digraph subgraph01 {
/* lot of nodes and edges */
}
subgraph02.dot
:
digraph subgraph02 {
/* lot of nodes and edges */
}
然后执行类似graph.dot
的操作:
digraph BigGraph {
import subgraph01;
import subgraph02;
A -> subgraph01.Node1
A -> subgraph02.Node1
subgraph01.Node10 -> subgraph02.Node99
/* etc. */
}
有办法吗?
推荐答案
我立即想到了两个选择.一种方法是使用宏处理器,例如 m4 .给定BigGraph.m4
:
Two options immediately occur to me. One would be to use a macro processor, e.g. m4. Given BigGraph.m4
:
digraph BigGraph {
define(`digraph',`subgraph')
include(`subgraph01.dot')
include(`subgraph02.dot')
A -> subgraph01.Node1
A -> subgraph02.Node1
subgraph.Node10 -> subgraph.Node99
/* etc. */
}
...正在运行:
$ m4 BigGraph.m4
...产生:
digraph BigGraph {
subgraph subgraph01 {
/* lot of nodes and edges */
}
subgraph subgraph02 {
/* lot of nodes and edges */
}
A -> subgraph01.Node1
A -> subgraph02.Node1
subgraph.Node10 -> subgraph.Node99
/* etc. */
}
另一个可能允许使用更复杂方法的选项是使用
GraphViz中的 gvpr .我尝试创建一个使用gvpr
进行此操作的示例,但是我没有成功,因此,我建议仅在需要图形感知方法而不是使用m4
的简单方法的情况下尝试此操作.
Another option that might allow a more sophisticated approach is to use
gvpr from GraphViz. I tried to create an example to do this with gvpr
, however and I was unsuccessful, so I suggest only trying it if a graph-aware approach is required rather than the simple approach using m4
.
这篇关于导入.dot文件作为子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!