Straitening one line throu a table

I want to create a line that ignors all “colisions” and goes straigth from one port to another in one table
I have:

graph {
// Graph generated by WireViz 0.3.2
// https://github.com/formatc1702/WireViz
	graph [bgcolor="#FFFFFF" fontname=arial nodesep=0.33 rankdir=LR ranksep=2]
	node [fillcolor="#FFFFFF" fontname=arial height=0 margin=0 shape=none style=filled width=0]
	edge [fontname=arial style=bold label=" "]

	X2 [label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">X2</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">P1</td>
   <td balign="left">9-pin</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
   <tr>
    <td port="p1l">1</td>
    <td>+28VDC</td>
    <td></td>
    <td  port="p1J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p2l">2</td>
    <td>+28VDC RTN</td>
    <td></td>
    <td></td>
    <td  port="p2J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
   </tr>
   <tr>
    <td port="p3l">3</td>
    <td>Token-In REF</td>
    <td  port="p3J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">&#11044;</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p4l">4</td>
    <td>Token-In</td>
    <td  port="p4J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p5l">5</td>
    <td>NC</td>
    <td></td>
    <td  port="p5J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p6l">6</td>
    <td>NC</td>
    <td></td>
    <td></td>
    <td  port="p6J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
   </tr>
   <tr>
    <td port="p7l">7</td>
    <td>RS-485+</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p8l">8</td>
    <td>RS-485-</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p9l">9</td>
    <td>RS-485 Shield</td>
    <td></td>
    <td  port="p9J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">⬤</FONT></td>
    <td></td>
   </tr>
  </table>
 </td></tr>
</table>
> fillcolor="#FFFFFF" shape=box style=filled]

	edge [color="#000000:#ff0000:#000000" label=" "]
	W1:w1:e -- X2:p1l:w
	edge [color="#000000:#000000:#000000" label=" "]
	W1:w2:e -- X2:p2l:w
	edge [color="#000000:#f5f0d0:#000000" label=" "]
	W1:w3:e -- X2:p7l:w
	edge [color="#000000:#0066ff:#000000" label=" "]
	W1:w4:e -- X2:p8l:w
	edge [color="#000000:#00ff00:#000000" label=" "]
	W1:w5:e -- X2:p9l:w

	edge [color="#000000" headclip=false, tailclip=false, style="dashed", constraint=false]
	X2:p1J:c -- X2:p5J:c[minlen=5]

	W1 [label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">W1</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">5x</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellborder="0">
   <tr><td>&nbsp;</td></tr>
   <tr>
    <td><!-- 1_in --></td>
    <td>
     1:RD
    </td>
    <td>X2:1:+28VDC</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#ff0000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 2_in --></td>
    <td>
     2:BK
    </td>
    <td>X2:2:+28VDC RTN</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 3_in --></td>
    <td>
     3:IV
    </td>
    <td>X2:7:RS-485+</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#f5f0d0" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 4_in --></td>
    <td>
     4:BU
    </td>
    <td>X2:8:RS-485-</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#0066ff" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 5_in --></td>
    <td>
     5:GN
    </td>
    <td>X2:9:RS-485 Shield</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#00ff00" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr><td>&nbsp;</td></tr>
  </table>
 </td></tr>
</table>
> fillcolor="#FFFFFF" shape=box style=filled]
}

this creates:

I want the dashed line going directly straight from one point to the point directly under it.

In the end the lines should look something like this:

For more reverence:
https://github.com/wireviz/WireViz/issues/286

Unfortunately, there is no attribute or command-line option that does what you want. (oddly, you get the loopy edges even if you used splines=false).
However, you can post-process your file and replace the loopy edge with a straight edge. I assume you could do it with Python, but here is a fix done with gvpr (https://www.graphviz.org/pdf/gvpr.1.pdf).
It runs dot with output format of dot (DOT | Graphviz) - text, but with all the nodes and edges positioned. That result is modified to replace the pos attribute for all edges that have the same node for tail & head. Graphviz straight-line edges are defined by 4 points(!) (or more), so that is what this program does.
Then neato with the -n2 command-line option (FAQ | Graphviz)

dot myFile.gv |
gvpr -c 'E[$.head==$.tail]{string tok[int];int cnt; cnt=tokens($.pos,tok," "); $.oldpos=$.pos;pos=tok[0]+" " + tok[0]+" "+tok[cnt-1]+" "+tok[cnt-1];}' |
neato -n2 -Tpng >myFile.png

Giving:

1 Like

Nice work, @steveroush.

Someday this should be made an intrinsic feature. This should also be the fallback mode for “lost edge” (though maybe those errors have mostly been squashed).

@steveroush Thank you for the answer,
when I try to run the command I get errors.
I am using Win10 with:

dot - graphviz version 10.0.1 (20240210.2158)

When I use the Terminal in VSCode I get:

C:\Program Files\Graphviz\bin\gvpr.exe: unclosed bracket {} expression, start line 1

When I use the Windows Terminal I get:

gvpr: expected keyword BEGIN/END/N/E...; found ''', line 1
Error: gvwrite_no_z problem 3285

I am a bit lost.

Steve’s script works for me (in a terminal in MacOS).

It seems to be a different problem, maybe character encoding? Maybe something weird happened in copy-paste?

Can you even run gvpr -c 'E[]{}’ in a terminal and type digraph G { a } on standard input and see the result?

Yes, if I do it this way it “works” without giving an error, but if I add the neato part the Image can not be opened.
The file input:

digraph G { a }

The Command I used:

dot .\t.gv | gvpr -c 'E[]{}' | neato -n2 -Tpng >t.png

Here is a reworked version that is easier to run and to understand. Save this file as pin2pin.gvpr:

/*******************************************************************

  see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196
  input must include pos values (must be output from one of the engines w/ -Tdot)
  
*******************************************************************/
BEG_G{
  string tok[int];
  int cnt;
}
/********************************************************
  the weakness is in the head==tail test
  it would be better to mark every target edge with a new attribute and test for that attribute
*********************************************************/
E[$.head==$.tail] {
  cnt=tokens($.pos,tok," ");
  $.oldpos=$.pos;
  pos=tok[0]+" " + tok[0]+" "+tok[cnt-1]+" "+tok[cnt-1];
}

Then run this windows cmd:
dot myFile.gv | gvpr -cf pin2pin.gvpr | neato -n2 -Tpng >myFile.png

p.s. Please note the weakness comment in the gvpr program

1 Like

Yes, works without an error, but the PNG is not readable(corrupted) and when using SVG as an output it looks like this(the forum would not even allow uploading it, had to put it in to Inkscape to export it as PNG and then upload it):

Ps. the line works if it is not comented out( :grin: :man_facepalming:)

And @steveroush how could one mark the desired target? So that the head tail test is not used, anymore.
Edit: figured that out alredy

For reverenc:
The dot output(dot .\test.gv )

graph {
        graph [bb="0,0,537.75,334",
                bgcolor="#FFFFFF",
                fontname=arial,
                nodesep=0.33,
                rankdir=LR,
                ranksep=2
        ];
        node [fillcolor="#FFFFFF",
                fontname=arial,
                height=0,
                label="\N",
                margin=0,
                shape=none,
                style=filled,
                width=0
        ];
        edge [color="#000000",
                constraint=false,
                fontname=arial,
                headclip=false,
                label=" ",
                style=dashed,
                tailclip=false
        ];
        X2      [height=3.6806,
                label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">X2</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">P1</td>
   <td balign="left">9-pin</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
   <tr>
    <td port="p1l">1</td>
    <td>+28VDC</td>
    <td></td>
    <td  port="p1J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">Ô¼ñ</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p2l">2</td>
    <td>+28VDC RTN</td>
    <td></td>
    <td></td>
    <td  port="p2J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">Ô¼ñ</FONT></td>
   </tr>
   <tr>
    <td port="p3l">3</td>
    <td>Token-In REF</td>
    <td  port="p3J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">&#11044;</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p4l">4</td>
    <td>Token-In</td>
    <td  port="p4J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">Ô¼ñ</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p5l">5</td>
    <td>NC</td>
    <td></td>
    <td  port="p5J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">Ô¼ñ</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p6l">6</td>
    <td>NC</td>
    <td></td>
    <td></td>
    <td  port="p6J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">Ô¼ñ</FONT></td>
   </tr>
   <tr>
    <td port="p7l">7</td>
    <td>RS-485+</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p8l">8</td>
    <td>RS-485-</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p9l">9</td>
    <td>RS-485 Shield</td>
    <td></td>
    <td  port="p9J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">Ô¼ñ</FONT></td>
    <td></td>
   </tr>
  </table>
 </td></tr>
</table>
>,
                pos="446.25,132.5",
                shape=box,
                width=2.5417];
        X2:p1J:c -- X2:p5J:c    [lp="446.25,297.25",
                pos="505.25,204.5 463.91,256.67 463.91,289 505.25,289 546.59,289 546.59,159.67 505.25,107.5",
                straight=true];
        X2:p5J:c -- X2:p9J:c    [lp="446.25,297.25",
                pos="505.25,107.5 463.91,159.67 463.91,289 505.25,289 546.59,289 546.59,63.667 505.25,11.5",
                straight=true];
        W1      [height=3.0417,
                label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">W1</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">5x</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellborder="0">
   <tr><td>&nbsp;</td></tr>
   <tr>
    <td><!-- 1_in --></td>
    <td>
     1:RD
    </td>
    <td>X2:1:+28VDC</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#ff0000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 2_in --></td>
    <td>
     2:BK
    </td>
    <td>X2:2:+28VDC RTN</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 3_in --></td>
    <td>
     3:IV
    </td>
    <td>X2:7:RS-485+</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#f5f0d0" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 4_in --></td>
    <td>
     4:BU
    </td>
    <td>X2:8:RS-485-</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#0066ff" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 5_in --></td>
    <td>
     5:GN
    </td>
    <td>X2:9:RS-485 Shield</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#00ff00" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr><td>&nbsp;</td></tr>
  </table>
 </td></tr>
</table>
>,
                pos="103.5,138.5",
                shape=box,
                width=2.875];
        W1:w1:e -- X2:p1l:w     [color="#000000:#ff0000:#000000",
                constraint="",
                headclip="",
                lp="280.88,188.75",
                pos="207,156.5 276.05,156.5 285.7,204.5 354.75,204.5",
                style=bold,
                tailclip=""];
        W1:w2:e -- X2:p2l:w     [color="#000000:#000000:#000000",
                constraint="",
                headclip="",
                lp="280.88,162.75",
                pos="207,129.5 276.47,129.5 285.28,180.5 354.75,180.5",
                style=bold,
                tailclip=""];
        W1:w3:e -- X2:p7l:w     [color="#000000:#f5f0d0:#000000",
                constraint="",
                headclip="",
                lp="280.88,89.75",
                pos="207,103.5 275.52,103.5 286.23,59.5 354.75,59.5",
                style=bold,
                tailclip=""];
        W1:w4:e -- X2:p8l:w     [color="#000000:#0066ff:#000000",
                constraint="",
                headclip="",
                lp="280.88,64.75",
                pos="207,77.5 275.27,77.5 286.48,35.5 354.75,35.5",
                style=bold,
                tailclip=""];
        W1:w5:e -- X2:p9l:w     [color="#000000:#00ff00:#000000",
                constraint="",
                headclip="",
                lp="280.88,40.75",
                pos="207,51.5 275.03,51.5 286.72,11.5 354.75,11.5",
                style=bold,
                tailclip=""];
}

the gvpr output(dot .\test.gv | gvpr -cf pin2pin.gvpr)

graph {
        graph [bb="0,0,537.75,334",
                bgcolor="#FFFFFF",
                fontname=arial,
                nodesep=0.33,
                rankdir=LR,
                ranksep=2
        ];
        node [fillcolor="#FFFFFF",
                fontname=arial,
                height=0,
                label="\N",
                margin=0,
                shape=none,
                style=filled,
                width=0
        ];
        edge [color="#000000",
                constraint=false,
                fontname=arial,
                headclip=false,
                label=" ",
                style=dashed,
                tailclip=false
        ];
        X2      [height=3.6806,
                label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">X2</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">P1</td>
   <td balign="left">9-pin</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1">
   <tr>
    <td port="p1l">1</td>
    <td>+28VDC</td>
    <td></td>
    <td  port="p1J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">???</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p2l">2</td>
    <td>+28VDC RTN</td>
    <td></td>
    <td></td>
    <td  port="p2J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">???</FONT></td>
   </tr>
   <tr>
    <td port="p3l">3</td>
    <td>Token-In REF</td>
    <td  port="p3J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">&#11044;</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p4l">4</td>
    <td>Token-In</td>
    <td  port="p4J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">???</FONT></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p5l">5</td>
    <td>NC</td>
    <td></td>
    <td  port="p5J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">???</FONT></td>
    <td></td>
   </tr>
   <tr>
    <td port="p6l">6</td>
    <td>NC</td>
    <td></td>
    <td></td>
    <td  port="p6J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0">???</FONT></td>
   </tr>
   <tr>
    <td port="p7l">7</td>
    <td>RS-485+</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p8l">8</td>
    <td>RS-485-</td>
    <td></td>
    <td></td>
    <td></td>
   </tr>
   <tr>
    <td port="p9l">9</td>
    <td>RS-485 Shield</td>
    <td></td>
    <td  port="p9J"><FONT FACE="Sans Not-Rotated 14" POINT-SIZE="13.0" COLOR="#0066ff">???</FONT></td>
    <td></td>
   </tr>
  </table>
 </td></tr>
</table>
>,
                pos="446.25,132.5",
                shape=box,
                width=2.5417];
        X2:p1J:c -- X2:p5J:c    [lp="446.25,297.25",
                oldpos="505.25,204.5 463.91,256.67 463.91,289 505.25,289 546.59,289 546.59,159.67 505.25,107.5",
                pos="505.25,204.5 505.25,204.5 505.25,107.5 505.25,107.5",
                straight=true];
        X2:p5J:c -- X2:p9J:c    [lp="446.25,297.25",
                oldpos="505.25,107.5 463.91,159.67 463.91,289 505.25,289 546.59,289 546.59,63.667 505.25,11.5",
                pos="505.25,107.5 505.25,107.5 505.25,11.5 505.25,11.5",
                straight=true];
        W1      [height=3.0417,
                label=<
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">W1</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>
   <td balign="left">5x</td>
  </tr></table>
 </td></tr>
 <tr><td>
  <table border="0" cellspacing="0" cellborder="0">
   <tr><td>&nbsp;</td></tr>
   <tr>
    <td><!-- 1_in --></td>
    <td>
     1:RD
    </td>
    <td>X2:1:+28VDC</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#ff0000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 2_in --></td>
    <td>
     2:BK
    </td>
    <td>X2:2:+28VDC RTN</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w2" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 3_in --></td>
    <td>
     3:IV
    </td>
    <td>X2:7:RS-485+</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w3" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#f5f0d0" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 4_in --></td>
    <td>
     4:BU
    </td>
    <td>X2:8:RS-485-</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w4" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#0066ff" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr>
    <td><!-- 5_in --></td>
    <td>
     5:GN
    </td>
    <td>X2:9:RS-485 Shield</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w5" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#00ff00" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>
   <tr><td>&nbsp;</td></tr>
  </table>
 </td></tr>
</table>
>,
                pos="103.5,138.5",
                shape=box,
                width=2.875];
        W1:w1:e -- X2:p1l:w     [color="#000000:#ff0000:#000000",
                constraint="",
                headclip="",
                lp="280.88,188.75",
                pos="207,156.5 276.05,156.5 285.7,204.5 354.75,204.5",
                style=bold,
                tailclip=""];
        W1:w2:e -- X2:p2l:w     [color="#000000:#000000:#000000",
                constraint="",
                headclip="",
                lp="280.88,162.75",
                pos="207,129.5 276.47,129.5 285.28,180.5 354.75,180.5",
                style=bold,
                tailclip=""];
        W1:w3:e -- X2:p7l:w     [color="#000000:#f5f0d0:#000000",
                constraint="",
                headclip="",
                lp="280.88,89.75",
                pos="207,103.5 275.52,103.5 286.23,59.5 354.75,59.5",
                style=bold,
                tailclip=""];
        W1:w4:e -- X2:p8l:w     [color="#000000:#0066ff:#000000",
                constraint="",
                headclip="",
                lp="280.88,64.75",
                pos="207,77.5 275.27,77.5 286.48,35.5 354.75,35.5",
                style=bold,
                tailclip=""];
        W1:w5:e -- X2:p9l:w     [color="#000000:#00ff00:#000000",
                constraint="",
                headclip="",
                lp="280.88,40.75",
                pos="207,51.5 275.03,51.5 286.72,11.5 354.75,11.5",
                style=bold,
                tailclip=""];
}

Our mistake. On Windows it is not safe to redirect stdout into a binary file like neato -Tpng > file.png

I think a standard library converts new lines or something like that.

Use -o file.png instead

1 Like

Yes works, thank you

After this, there is white/empty space over the table, which is because there were originally lines there. Is there a way to remove this, by “recicing” the drawing area or so?

Yes, neato seems to be computing its own bounding box using loopy edges, even though we provide non-loopy edges. Weird!

Is this a one-time need or do you want a fix that can be used many times?

A fix that can be used many times, since this is meant to be used with a Python script that creates the diagram(wiring plan)

Ahh, it wasn’t a neato oddity. Neato was just following orders. The input file set label=" " for all edges, so dot calculated a pos (.lp) for the loopy edge. That caused the extra headroom.
Here is a modified pin2pin that removed the label and the lp.

/*******************************************************************

  see https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196
  input must include pos values (must be output from one of the engines w/ -Tdot)
  
*******************************************************************/
BEG_G{
  string tok[int];
  int cnt;

/***************************************
  $G.bb="";
  $G.nodesep="";
  $G.ranksep="";
  $G.splines="true";
****************************************/
}
/********************************************************
  the weakness is in the head==tail test
  it would be better to mark every target edge with a new attribute and test for that attribute
*********************************************************/
E[$.head==$.tail] {
  cnt=tokens($.pos,tok," ");
  $.oldpos=$.pos;
  pos=tok[0]+" " + tok[0]+" "+tok[cnt-1]+" "+tok[cnt-1];
  $.label="";  // remove pesky label
  $.lp="";      // remove peskier label pos
}

Giving:

@steveroush Thank you works

Once again a follow-up problem, when having multicolor edges(color="#000000:#f5f0d0:#000000") the following happens(in table W1):

	edge [color="#000000:#ff0000:#000000" label=" "]
	W1:w1:e -- W1:w1:w[straight=straight]

or

	edge [color="#000000:#ff0000:#000000" label=" "  penwidth=6]
	W1:w1:e -- W1:w1:w[straight=straight]

The aim is to make edges with even more colors:

Is there a way to prevent this pointing/sharpening to the node and instead have a flat end?

My guess is the narrowing is caused by a bug. You can report it here: Issues · graphviz / graphviz · GitLab