nickotinus
nickotinus

Reputation: 323

Control Graphviz arrows direction

I'm tying to draw the IDEF0 diagram example using Graphviz 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" 
}

The problem is that I can't find the way to control direction of arrows around the central box.

I've tried to use hidden "frame" made of invisible South, North, East and West nodes to connect arrows to them. Unfortunately the "frame" works well only if it is empty, and when I connect my "payload" nodes to it, the structure breaks:

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

Is the any correct way to implement this diagram style?

Upvotes: 1

Views: 2420

Answers (1)

vaettchen
vaettchen

Reputation: 7659

Using shape = record brings you close to what you want - here my re-written attempt:

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

yields

enter image description here

E D I T 2018-11-29

In order to avoid the issues that @McKay has shown in his comment, I have re-coded the sample using a HTML like label:

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

Which gives us

enter image description here

without warning or error message on my Linux box with graphviz version 2.38.0 (20140413.2041).

Upvotes: 4

Related Questions