2017-05-18 73 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