【问题标题】:How to write long labels just once, and use references to them in the graph?如何只写一次长标签,并在图中使用对它们的引用?
【发布时间】:2020-09-13 19:42:59
【问题描述】:

我在节点上有一些长标签。因为节点是相互连接的(当然),因此完全相同的标签出现在几个地方,每次我需要编辑其中一个时,我都必须手动更改它们多次,这是时间-消耗和容易出错(或复制一次,然后查找+替换;这只是稍微不那么烦人)。

所以,不要像这样:

digraph {
    "Some very long label" -> "Another label with elaborate text"
    "Some very long label" -> "Red blue green yellow"
    "Another label with elaborate text" -> "Blah bleh bleh blah"
    "Blah bleh bleh blah" -> "Sooo annoying! Really!"
}

我想做一些这样的事情(编造的语法):

digraph {

    // Structure:
    #A -> #B
    #A -> #C
    #B -> #C
    #B -> #D
    #D -> #E

    // Label definitions:
    #A: "Some very long label"
    #B: "Another label with elaborate text"
    #C: "Red blue green yellow"
    #D: "Blah bleh bleh blah"
    #E: "Sooo annoying! Really!"

}

这可能吗?

【问题讨论】:

    标签: graphviz dot


    【解决方案1】:

    我认为您在正确的轨道上,只是语法错误。如何为节点使用 id 并设置适当的标签,例如:

    digraph G{
        N1 [label="Some very long label"]
        N2 [label="Another label with elaborate text"]
        N3 [label="Red blue green yellow"]
        N4 [label="Blah bleh bleh blah"]
        N5 [label="Sooo annoying! Really!"]
    
        N1 -> N3
        N2 -> N4
        N1 -> N2
        N4 -> N5
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-23
      • 2021-07-19
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多