# Dot problem, two edges are not combined

**URL:** <https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101>\
**Category:** Help\
**Created:** [March 29, 2024, 4:16pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101 "2024-03-29T16:16:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tim](https://forum.graphviz.org/u/Tim)\
**Post date:** [March 29, 2024, 4:16pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101/1 "2024-03-29T16:16:27Z")

</div>

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](https://global.discourse-cdn.com/graphviz/original/2X/7/721b82effd5262c5d34223b77d13c49440b9b7f7.jpeg)  
 ![IMG_4922](https://global.discourse-cdn.com/graphviz/original/2X/f/fb4ababf5eef09858d281c7191c2c1aab2059cca.jpeg)

```auto
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 

}

```

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 30, 2024, 1:30pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101/2 "2024-03-30T13:30:20Z")

</div>

[this discussion started on stackoverflow ([graphviz arrow, node, table - I'm looking for a solution to avoid a double arrow? - Stack Overflow](https://stackoverflow.com/questions/78233293/graphviz-arrow-node-table-im-looking-for-a-solution-to-avoid-a-double-arrow)). 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](https://www.graphviz.org/pdf/gvpr.1.pdf)

```auto
/ **********************************************************************
  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:

```auto
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.circo](https://global.discourse-cdn.com/graphviz/original/2X/6/65dda87ead2199fd9650a5e3be317cfaec4d62f4.png)

![concentratePort0.dot](https://global.discourse-cdn.com/graphviz/original/2X/5/58e2ecd4fc6073d7afbe8e45bfcd07b87c916193.png)

 ![concentratePort0.fdp](https://global.discourse-cdn.com/graphviz/original/2X/9/9dba6b58a923506b3575f766459eb137ea411df3.png)

 ![concentratePort0.neato](https://global.discourse-cdn.com/graphviz/original/2X/f/f47f6dee037c11d3cdc6bc489b02981a741ecdad.png)

 ![concentratePort0.twopi](https://global.discourse-cdn.com/graphviz/original/2X/e/e0599f77f9a133f03a871eafc794b61266c14878.png)

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [May 24, 2024, 6:49pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101/4 "2024-05-24T18:49:44Z")

</div>

Can you provide source to the two graphs you included?

---

<div class="post-metadata">

**Author:** ![Tim](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tim](https://forum.graphviz.org/u/Tim)\
**Post date:** [May 24, 2024, 7:44pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101/5 "2024-05-24T19:44:36Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Tim](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tim](https://forum.graphviz.org/u/Tim)\
**Post date:** [May 25, 2024, 12:29pm UTC](https://forum.graphviz.org/t/dot-problem-two-edges-are-not-combined/2101/6 "2024-05-25T12:29:46Z")

</div>

[testflooruni.dot](https://forum.graphviz.org/uploads/short-url/cqwdSBYx19szic4MUQ1Rv29zQ4Z.dot) (3.6 KB)  
[testfloor.dot](https://forum.graphviz.org/uploads/short-url/q9G3QNyt8whqP0qACr2FW2gO42.dot) (3.8 KB)

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

 ![testfloor](https://global.discourse-cdn.com/graphviz/original/2X/c/c62493a4cf9153c0a0ebf0d0e5fc4b79fe35dcc7.jpeg)  
uni - short  
 ![testflooruni](https://global.discourse-cdn.com/graphviz/original/2X/3/3dc131c703e303188321a9c2b4f0d77542d44df5.jpeg)

I cannot influence the order of nodes and connections
