控制Graphviz箭头方向

时间:2017-10-17 13:03:34

标签: graphviz

我想用Graphviz IDEF0

绘制enter image description here图表示例
digraph UDEF0 {
 "Plan New Information Program" [shape=box]
 "Issues"                       [shape=none]
 "Operation Data"               [shape=none]
 "Program Charter"              [shape=none]
 "Program Team"                 [shape=none]
 "Program Plan"                 [shape=none]

 "Issues" ->            "Plan New Information Program"
 "Operation Data" ->    "Plan New Information Program"

 "Program Charter" ->   "Plan New Information Program"

 "Program Team" ->      "Plan New Information Program"

 "Plan New Information Program" -> "Program Plan" 
}

问题是我无法找到控制中央盒子周围箭头方向的方法。

我试图使用由不可见的南,北,东和西节点组成的隐藏“框架”来连接箭头。不幸的是,“框架”只有在它是空的时才能正常工作,当我将“有效载荷”节点连接到它时,结构会断开:

digraph UDEF0 {
   rankdir=LR
   "Plan New Information Program" [shape=box]
   "Issues"                       [shape=none]
   "Operation Data"               [shape=none]
   "Program Charter"              [shape=none]
   "Program Team"                 [shape=none]
   "Program Plan"                 [shape=none]
   "Program Plan"                 [shape=none]


   "West"                 [shape=none]
   "North"                 [shape=none]
   "South"                 [shape=none]
   "East"                 [shape=none]
   "West" -> "North" -> "East"
   "West" -> "South" -> "East"


   "West" -> "Issues" ->            "Plan New Information Program"
   "West" -> "Operation Data" ->    "Plan New Information Program"

   "North" -> "Program Charter" ->   "Plan New Information Program"

   "South" -> "Program Team" ->      "Plan New Information Program"

   "East" -> "Plan New Information Program" -> "Program Plan"
}

是否有正确的方法来实现此图表样式?

1 个答案:

答案 0 :(得分:2)

使用shape = record让你接近你想要的东西 - 这是我重写的尝试:

digraph UDEF0
{
    A[ label = "Plan New\nInformation\nProgram", shape=box, style = filled, fillcolor = grey ]
    B[ shape = record, color = white, label = "{ Operation Data | Issues }" ]
    node[ shape = none ]
    c[ label = "Program Charter" ]
    d[ label = "Program Team" ]
    e[ label = "Program Plan" ] 

    { rank = same; A B e }

    c -> A;
    A -> d[ dir = back ];
    edge[ minlen = 3]
    B -> A;
    B -> A;
    A -> e;
}

产量

enter image description here

E D I T 2018-11-29

为了避免@McKay在评论中显示的问题,我使用类似HTML的标签对示例进行了重新编码:

digraph UDEF0
{
    A[ label = "Plan New\nInformation\nProgram", shape=box, style = filled, fillcolor = grey ]

    B[ shape = plaintext, label =<
    <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="15">
        <TR>
            <TD PORT = "p1">Issues</TD>
        </TR>
        <TR>
            <TD PORT = "p2">Operation Data</TD>
        </TR>
    </TABLE>>];

    node[ shape = none ]
    c[ label = "Program Charter" ]
    d[ label = "Program Team" ]
    e[ label = "Program Plan" ] 

    { rank = same; A B e }

    c -> A;
    A -> d[ dir = back ];
    edge[ minlen = 3]
    B:p1 -> A;
    B:p2 -> A;
    A -> e;
}

这给了我们

enter image description here

graphviz version 2.38.0 (20140413.2041)的Linux机器上没有警告或错误消息。