2017-05-18 76 views
0

我正在绘制大量节点的大图,这些节点呈现在点dot -Tsvg graph.gv -o graph.svg中。 为了保持概览我“明确”地定义了我在图的开头使用的所有节点。强制显式创建节点(点,graphviz)

现在我正在寻找一种方法来确保只有那些“显式”定义的节点被使用,并且我没有在边界定义(例如节点名称中的拼写错误)上“隐式”地创建节点。

以下图形的渲染不应起作用,或者在渲染使用“隐式”节点时发出警告。

graph main_graph { 

    // explicit node definition 
    node1[style=filled, color=grey]; 
    node2[style=filled, color=grey]; 
    node3[style=filled, color=grey]; 

    subgraph graph1 { 
    edge [color=red,penwidth=2] 
    node0 -- node2; //node0 implicitly defined 
    } 

    subgraph graph2 { 
    edge [color="blue",penwidth=2] 
    node2 -- node3; 
    node1 -- node3; 
    } 
} 

回答

1

官方支持不存在。

我用下面的提示。

1.一种用于隐式节点

graph main_graph { 

    // explicit node definition 
    node1[style=filled, color=grey]; 
    node2[style=filled, color=grey]; 
    node3[style=filled, color=grey]; 

    // ---- lower boundary of explicit node definition ---- 
    // default node attribute used for the detection of implicit node definition 
    node[label="IMPLICITLY-DEFINED"] 

    subgraph graph1 { 
    edge [color=red,penwidth=2] 
    node0 -- node2; //node0 implicitly defined 
    } 

    subgraph graph2 { 
    edge [color="blue",penwidth=2] 
    node2 -- node3; 
    node1 -- node3; 
    } 
} 

2.添加标记查找标记为隐式定义的节点

$ dot -Tplain graph.gv | awk '/IMPLICITLY-DEFINED/{print $2}' 
node0 

测试版本:graphviz的版本2.40.1(20161225.0304)在macOS上

+0

看起来像一个很好的解决方法,我会保持打开周末s检查其他r的想法,然后接受最好的答案。 – RonaldFindling