Dot problem, two edges are not combined

I generate a code for graphviz. This network plan always contains 2 arrows for there and back directions. Unfortunately, 2 separate arrows are displayed in the example - but I don’t want that…
but with „splines=false“, I can prevent the double arrows. how do I make sure the arrows don’t cross the nodes?

IMG_4923
IMG_4922

digraph {
    node [shape=box, style=filled, fillcolor=navajowhite1];
    graph [bgcolor=floralwhite, overlap=false, splines=true, rankdir=LR, concentrate=true];
    edge[arrowhead="normal", color="darkblue", arrowsize=0.75];
CCC [label=<
		<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" color="black">
		<TR><TD><B>10.182.2.3</B></TD></TR> 
		<TR><TD>CCC</TD></TR> 
		<TR><TD>Switch3</TD></TR> 
		<TR><TD PORT="111">1/1/1</TD></TR>
		<TR><TD PORT="161">1/6/1</TD></TR>
		</TABLE>>];
EEE [label=<
		<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" color="black">
		<TR><TD><B>10.182.2.5</B></TD></TR>
		<TR><TD>EEE</TD></TR>
		<TR><TD>Switch5</TD></TR>
		<TR><TD PORT="111">1/1/1</TD></TR>
		<TR><TD PORT="121">1/2/1</TD></TR>
		<TR><TD PORT="161">1/6/1</TD></TR>
		</TABLE>>];


AAA [label=<
		<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" color="black">
		<TR><TD><B>10.182.2.1</B></TD></TR>
		<TR><TD>AAA</TD></TR>
		<TR><TD>Switch1</TD></TR>
		<TR><TD PORT="111">1/1/1</TD></TR>
		<TR><TD PORT="121">1/2/1</TD></TR>
		<TR><TD PORT="161">1/6/1</TD></TR>
		</TABLE>>];


BBB [label=<
		<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" color="black">
		<TR><TD><B>10.182.2.2</B></TD></TR>
		<TR><TD>BBB</TD></TR>
		<TR><TD>Switch2</TD></TR>
		<TR><TD PORT="141">1/4/1</TD></TR>
		<TR><TD PORT="151">1/5/1</TD></TR>
		</TABLE>>];



DDD [label=<
		<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" color="black">
		<TR><TD><B>10.182.2.4</B></TD></TR>
		<TR><TD>DDD</TD></TR>
		<TR><TD>Switch4</TD></TR>
		<TR><TD PORT="141">1/4/1</TD></TR>
		<TR><TD PORT="151">1/5/1</TD></TR>
		</TABLE>>];


BBB:141 -> CCC:161
BBB:151 -> AAA:121 

AAA:111 -> EEE:161 
AAA:121 -> BBB:151 
AAA:161 -> DDD:141 

CCC:111 -> DDD:151 
CCC:161 -> BBB:141 

DDD:141 -> AAA:161 
DDD:151 -> CCC:111 

EEE:161 -> AAA:111 


}

[this discussion started on stackoverflow (graphviz arrow, node, table - I'm looking for a solution to avoid a double arrow? - Stack Overflow). I think the Forum is a better place to finish it.]

  • Your source file seems perfectly “legal”. Unfortunately, you seem to be encountering bug(s) or odd “works as designed” results (more later)
  • I can find no combination of layout engines and attributes that will produce the graph you want, without eliminating (duplicated) edges and adding the attribute dir=both
  • here is a gvpr program that identifies duplicated edges (with head & tail reversed), deletes one, and adds dir=both to the “survivor”. gvpr is documented here: https://www.graphviz.org/pdf/gvpr.1.pdf
/**********************************************************************
  assumes 2 edges with tail & head "swapped"
  - changes "dir" of 1st to "both"
  - deletes the 2nd
**********************************************************************/
BEG_G{
  int    edgeExists[], deleteIt[];
  obj_t  Obj;
  string tmpS, headP, tailP;
}
E{
  if (hasAttr($, "tailport") && $.tailport!="")
    tailP=$.tailport;
  else
    tailP="";
  if (hasAttr($, "headport") && $.headport!="")
    headP=$.headport;
  else
    headP="";
  tmpS=$.head.name + "_" + headP + "-" + $.tail.name + "_" + tailP;
  if (edgeExists[tmpS]==1)
    deleteIt[$]=1;
  else
    $.dir="both";
  tmpS=$.tail.name + "_" + tailP + "-" + $.head.name + "_" + headP;
  edgeExists[tmpS]=1;
}
END_G{
  for (deleteIt[Obj])
    delete($G, Obj);
}

A (Linux) command line to use it:

gvpr -cf combineEdges.gvpr myFile.gv | dot -Tpng >myFile.png
  • The documentation for concentrate is somewhat ambiguous, but it is minimally annoying that it produces different results depending on the layout engine, the value for the splines attribute, and the nature of the individual edges. I will create an Issue describing the problem. (I think it is a set of bugs).
  • It appears that your network is not particularly hierarchical. Below are results of using other layout engines. For this subset, I like circo best, but neato might be best for your complete graph.

concentratePort0.dot

Hello,
I tried circo, neato, fdp with about 200 network elements and, due to the horizontal arrangement of the ports, decided that it is best represented with dot. Now I have converted all bidirectional connections to unidirectional and let them be drawn. Unfortunately, the result was moderately unsatisfactory. The reason for this is the limited compact representation with LR orientation. The automatic arrangement works well only with bidirectional connections. Unfortunately, I have the original problem with the double arrows here. :frowning:

Converting individual duplicated connections to unidirectional does not help either, because during compilation, they are either automatically redrawn, or the direction a->b and b->a must be correctly specified. With the large number and frequent updates of the connection data, this is not practical, unfortunately…

Have I perhaps overlooked something?


Can you provide source to the two graphs you included?

Unfortunately, I cannot share the source file due to client confidentiality, as it requires time to convert headers and content. In principle, this is just an extension of the first post. Approximately 95% of the connections are bidirectional, 5% unidirectional…

testflooruni.dot (3.6 KB)
testfloor.dot (3.8 KB)

long, for me better (a jump over an element causes 2 arrows?)


uni - short

I cannot influence the order of nodes and connections