【问题标题】:Enforce explicit node creation (dot, graphviz)强制创建显式节点(dot、graphviz)
【发布时间】:2017-05-19 13:40:03
【问题描述】:

我正在处理一个包含大量节点的大图,这些节点以点 dot -Tsvg graph.gv -o graph.svg 呈现。 为了保持概览,我“明确”定义了我在图表开头使用的所有节点。

现在我正在寻找一种方法来确保仅使用那些“显式”定义的节点,并且不会在边缘定义上获得“隐式”创建的节点(例如节点名称中的拼写错误)。

下图的渲染不应该工作或在渲染时警告我使用了“隐式”节点。

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;
  }
}

【问题讨论】:

    标签: graphviz dot


    【解决方案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
    

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

    【讨论】:

    • 似乎是一个很好的解决方法,我会在周末保持打开状态以检查其他想法,然后接受最佳答案。
    猜你喜欢
    • 2011-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多