Graphviz/dot - visualizing data with nodes acting like edges

As a Graphviz newbe I have looked for and tried multiple suggestions found on the web, but none seemed to really work:

Requirement: Consider graphing entities and relations (data instances, not the schema). In the simple case an entity is a node and a relation an edge (perhaps with labels on one or both ends). In some cases relations need to be "reified" (made real) and thus have the capabilities of nodes. This is so they could have their own edges, properties, etc.

When this is graphed I would like these relation-nodes to act like edges, they should just be positioned in-between the entities they connect. By the way, I also have text nodes representing primitive data.

Problem: Whenever I make the relation-nodes they want to "rank" above the entities and they "take over" the layout. I have tried variations of many properties without success. The layout is "mostly hierarchical" but not strictly so - I am currently using "dot". I have tries subgraphs and clusters without success - but the data is mostly "flat". I am using Python-pydot, but I don't think that matters.

Question: How can I represent data with relation-nodes that renders in a reasonable way in Graphviz. Alternatively, is there a better package to use? The enclosed graph shown the way the relations tend to graph - the ovals should be between the boxes..

AttachmentSize
datagraph.png80.99 KB

Whenever you have an edge a

Whenever you have an edge a -- b or a -> b in a graph given to dot, the algorithm will place b below a. Given the output, I assume you have written your edges so the a is relation-node and b is a related entity-node. So dot is doing what it is supposed to, given the input. If you wish to have a relation-node between its two entity-nodes, you need to specify how this division is done. If your graph is bipartite (ignoring relation-nodes), you can always split the entity-nodes to be either above or below all of its relation-nodes. (If the entity graph is not bipartite, this is not possible. The best you can do in that case is use flat edges to get what you want.)

 

digraph ER {
   overlap=false
   edge[dir=none]
   { node[shape=box]
      Package1 Indicator Plan "Modus Operandi"
   }
   { node[fontcolor=green]
      Text1 Text2 Text3 Text4 Text5
   }
   Text1 -> R1 -> Package1
   Indicator -> R2 -> Package1
   Indicator -> R3 -> Text2
   Indicator -> R4 -> Text3
   Indicator -> R5 -> Text4
   Indicator -> R6 -> "Modus Operandi"
   Plan -> R7 -> "Modus Operandi"
   Text5 -> R8 -> "Modus Operandi"
   Text5 -> R9 -> "Modus Operandi"
   Text6 -> R10 -> "Modus Operandi"
   Package2 -> R11 -> "Modus Operandi"
   Package2 -> R12 -> Text7
}

In truth, your graph is only locally hierarchical, so you may be better off using neato or sfdp to do the layout.

Recent comments