A program to "fix" simple edges

alterSimpleEdge is a gvpr post-processor that allows the user to replace individual splined edges with pseudo ortho, curved, or straight edges. Pseudo, in that it does not use the standard Graphviz algorithms - for better and for worse.

  • Better:
    • edges types can be mixed
    • edges can be “sized” (e.g. deeper or shallower curve)
    • edge direction can be set (e.g. clockwise or counter-clockwise)
    • works with ports (true ortho does not)
    • seems to support some implementations of a bus structure
  • Worse:
    • Dumber than a box of rocks
      • no compound curves or equivalent ortho edges (see below)
      • ortho needs explicit help setting direction of the three line segments (this can be improved)
      • does not consider positions of other nodes or edges
      • requires all nodes to already be positioned
      • does not reposition arrowheads, but will rotate arrowheads to align tith new splines

It is not well tested & is ugly code, but if you are brave, you can find it here: Graphviz post-processor to customize edges · GitHub

Example:

Input:

digraph S{
 rankdir=LR
  nodesep=1.0

  edge [edgeType=curved ] 
  node [shape=record]
  
  A [shape=record label="{<p1>123|<p2>45  54|<p3>a e i o u}"]
  CDE    [shape=record label="<p1>C|<p2>D|<p3>E"]
  A:p1:n -> CDE:p2
  A:p2:c -> CDE:p2
  A:p3:s -> CDE:p2  [edgeDirection=ccw]
  
   struct1 [ shape =record, label = "<p1>a|<p2>b|<p3>c" ];
   struct2 [ shape =record, label = "a|{<p1>b1|b2}|c" ];
   
   struct1:p1:n -> struct2:p1
   struct1:p1:n -> struct2:p1   [edgeDirection=ccw]
   edge[edgeDirection=ccw]
   struct1:p1:w -> struct1:p2:w
   struct1:p2:w -> struct1:p3:w
   struct1:p1:w -> struct1:p3:w  [edgeOffset="54"]

  ///////////////////////////////////////////////////////////////////
  edge [edgeType=ortho  edgeDirection=nes] 
  
  A1 [shape=record label="{<p1>123|<p2>45  54|<p3>a e i o u}"]
  B1    [shape=record label="{<p1>C|<p2>D|<p3>E}"]
  A1:p1:n -> B1:p2:n  
  A1:p2:n -> B1:p2:n
  A1:p3:s -> B1:p2:s  [edgeDirection=sen]
  
   S1 [ shape =record, label = "<p1>a|<p2>b|<p3>c" ];
   S2 [ shape =record, label = "<p0>a|{<p1>b1|b2}|c" ];
   S1:p1:n -> S2:p0:n
   S1:p1:n -> S2:p0:n    [edgeType=curved]
   edge[edgeDirection=wse]
   S1:p1:w -> S1:p2:w
   S1:p2:w -> S1:p3:w

   // old struct node
   edge[edgeDirection=wse]
   struct1:p1:w -> struct1:p2:w
   struct1:p2:w -> struct1:p3:w
  }
2 Likes

Same offer as always; please feel free to submit this as an MR to the Graphviz repo.

This program is a mess & poorly tested - it evolved/mutated over many months.
I hope to continue to test it and do a major code cleanup. Then submit it.

Your offer reminds me that I do have some simpler and better tested programs that might prove useful. I’ll look into submitting them.

thanks

1 Like