# How to make child nodes not interweaved

**URL:** <https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429>\
**Category:** Uncategorized\
**Created:** [September 5, 2024, 5:52pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429 "2024-09-05T17:52:50Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 5, 2024, 5:52pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/1 "2024-09-05T17:52:50Z")

</div>

Greetings!

I have a root with a few child nodes(e.g. A, B, C, A1, B1, C1). By default, the children surround the root node and connected nicely, Except, the children nodes interweaved, like A, B, A1, C, B1, C1, sequentially. I hope they can display as the defined order, or at least the first 3 stay together, and same as the rest. I know I can use subgraph method, but the children nodes are flatly displayed. Is there a way to have the default surrounding, but make the children nodes not interweaved (or mixed).

Thank you in advance!

Sincerely,  
Josh

---

<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:** [September 5, 2024, 7:45pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/2 "2024-09-05T19:45:38Z")

</div>

Will you share your source file?

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 5, 2024, 8:05pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/3 "2024-09-05T20:05:53Z")

</div>

Thank you for your replying.

I am posting the dot file below. As you see, I used “neato” engine to generate the image nicely, except the issue of “interweaving”. If I use “circo” engine, it seems to solve the ‘interweave’ issue, but the length of the edges are very long. especially, when graphs have multiple layers of nodes, the image is not very good looking.

Not sure, if I am missing anything…

Hope to have your advice.

Josh

======================  
graph ER {  
graph [fontname=“Helvetica,Arial,sans-serif,Microsoft YaHei”]  
node [fontname=“Helvetica,Arial,sans-serif,Microsoft YaHei”]  
edge [fontname=“Helvetica,Arial,sans-serif,Microsoft YaHei”]

```
		layout=neato;
		overlap = false;
		sep = "+10";
		splines = true;
		pack = true;
		packmode = "node";

                  node [shape="polygon", style="solid", color="black"]; {node [label="abbreviation"] abbreviation}; 

```

node [shape=“ellipse”, style=“solid”, color=“red”]; {node [label=“abridgement”] abbreviation\_abridgement};  
abbreviation\_abridgement – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“red”]; {node [label=“digest”] abbreviation\_digest};  
abbreviation\_digest – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“red”]; {node [label=“reduction”] abbreviation\_reduction};  
abbreviation\_reduction – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“red”]; {node [label=“symbol”] abbreviation\_symbol};  
abbreviation\_symbol – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“blue”]; {node [label=“enlargement”] abbreviation\_enlargement};  
abbreviation\_enlargement – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“blue”]; {node [label=“extension”] abbreviation\_extension};  
abbreviation\_extension – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“blue”]; {node [label=“expansion”] abbreviation\_expansion};  
abbreviation\_expansion – abbreviation;  
node [shape=“ellipse”, style=“solid”, color=“blue”]; {node [label=“increase”] abbreviation\_increase};  
abbreviation\_increase – abbreviation;

```
		label = "Synonyms and Antonyms";
		fontsize=16 ;
	}

```

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 5, 2024, 8:08pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/4 "2024-09-05T20:08:16Z")

</div>

should have made the file attachment.  
[dot\_file.txt](https://forum.graphviz.org/uploads/short-url/7lCzIA338EiU6brBnB1O8fpdcqY.txt) (1.7 KB)

---

<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:** [September 5, 2024, 9:42pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/5 "2024-09-05T21:42:44Z")

</div>

Can you share a graph with “multiple layers of nodes”?  
And maybe a sketch of what result you want.

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 5, 2024, 10:28pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/6 "2024-09-05T22:28:15Z")

</div>

Attached please find one more layer of node. if modifying the engine to “circo”, you may review the graph  
[dot\_file2.txt](https://forum.graphviz.org/uploads/short-url/kVceXDBiJT0mH0PpJOCGHjBE9aG.txt) (3.8 KB)

---

<div class="post-metadata">

**Author:** ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)\
**Post date:** [September 6, 2024, 12:16am UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/7 "2024-09-06T00:16:52Z")

</div>

My monthly PSA: the forum supports code blocks with Graphviz syntax highlighting:

````auto
```dot
digraph {
  like -> so[with="a label"];
}
```

````

which produces:

```dot
digraph {
  like -> so[with="a label"];
}

```

---

<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:** [September 6, 2024, 4:14am UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/8 "2024-09-06T04:14:24Z")

</div>

Not sure exactly what the desired result is, but here are some partial answers. I’m happy to try again with a bit more guidance.

- There is probably no way to guarantee that **neato** will lay out the nodes in the order that they appear in the input. I tried 40+ variations of **neato** with different attributes, but no joy. Sorry.
- **neato** did do a reasonable job on the second example (to my eye). So did **circo** & **twopi**.
- Below, is a reworked version of the first, to make it simpler. The original is “legal”, but overly complex (again to my eye). The subgraphs do not accomplish anything.

```auto
graph ER {
  graph [fontname="Helvetica,Arial,sans-serif,Microsoft YaHei"]
  node [fontname="Helvetica,Arial,sans-serif,Microsoft YaHei"]
  edge [fontname="Helvetica,Arial,sans-serif,Microsoft YaHei"]

// layout=neato; commented to make it easier to try other engines
  overlap = false;
  sep = "+10";
  splines = true; // do you want splines?
  // not sure, but I doubt that pack & packmode are helpful here
  // pack = true;
  // packmode = "node";

  // rearranged code
  // the subgraphs {...} did not accomplish anything
  
  node [shape="polygon", style="solid", color="black" label="abbreviation"] abbreviation
  node [shape="ellipse", style="solid", color="red" label="abridgement"] abbreviation_abridgement
  abbreviation_abridgement -- abbreviation;
  
  node [shape="ellipse", style="solid", color="red" label="digest"] abbreviation_digest
  abbreviation_digest -- abbreviation;
  
  node [shape="ellipse", style="solid", color="red" label="reduction"] abbreviation_reduction
  abbreviation_reduction -- abbreviation;
  
  node [shape="ellipse", style="solid", color="red" label="symbol"] abbreviation_symbol
  abbreviation_symbol -- abbreviation;
  
  node [shape="ellipse", style="solid", color="blue" label="enlargement"] abbreviation_enlargement
  abbreviation_enlargement -- abbreviation;
  
  node [shape="ellipse", style="solid", color="blue" label="extension"] abbreviation_extension
  abbreviation_extension -- abbreviation;
  
  node [shape="ellipse", style="solid", color="blue" label="expansion"] abbreviation_expansion
  abbreviation_expansion -- abbreviation;
  
  node [shape="ellipse", style="solid", color="blue" label="increase"] abbreviation_increase
  abbreviation_increase -- abbreviation;

  label = "Synonyms and Antonyms";
  fontsize=16 ;
}

```

Here are examples of the second graph, using **neato** , **circo** , and **twopi**.

 ![interweaveTwo1.circo](https://global.discourse-cdn.com/graphviz/original/2X/c/c037517696baa857110d739db83ab1eae18e1978.png)  
 ![interweaveTwo1.neato](https://global.discourse-cdn.com/graphviz/original/2X/6/61a36fc15a9d503b89b5f8466db8786eda80f72d.png)  
 ![interweaveTwo1.twopi](https://global.discourse-cdn.com/graphviz/original/2X/7/7daddace63d7482e083541200c1e202bfc692775.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:** [September 6, 2024, 12:47pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/9 "2024-09-06T12:47:57Z")

</div>

Here is a simple addition your original input that seems to produce what you want. Invisible edges connect the nodes in sequence. It is shown here as all on one line just because I am a lazy typist.

```auto
edge [style=invisible]
abbreviation_abridgement -- abbreviation_digest -- abbreviation_reduction -- abbreviation_symbol -- abbreviation_enlargement -- abbreviation_extension -- abbreviation_expansion -- abbreviation_increase -- abbreviation_abridgement

```

Gives:

 ![interweave01](https://global.discourse-cdn.com/graphviz/original/2X/d/d8439c42ac095843d465dcab651978cfce0def56.png)

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 6, 2024, 11:31pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/10 "2024-09-06T23:31:27Z")

</div>

Greetings!

It seems that I got some issues in my windows. Attached please find the graphs that generated in my local. I got better graphs in the “Edit in Playground” on your website. Not sure what is the issue.  
I tried both methods (i.e., installed and unzip). Both could not make as good as that in your website. The rectangle is not correct also.

Josh

[dot-file-1.txt](https://forum.graphviz.org/uploads/short-url/yJeAfWyxAwNYGVndh5co1raeW9w.txt) (4.2 KB)

 ![abandon](https://global.discourse-cdn.com/graphviz/original/2X/9/962a6649b1fe9c9d163fe39bb739d9ae1f7adc40.png)  
 ![abbreviation](https://global.discourse-cdn.com/graphviz/original/2X/1/193129cf4af3bbc5bb56ef48c9fada14ce8e432f.png)

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 6, 2024, 11:40pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/11 "2024-09-06T23:40:39Z")

</div>

[dot-file-2.txt](https://forum.graphviz.org/uploads/short-url/wFSOxL4TNMFQuC1Dlw6CxEfhi3t.txt) (1.8 KB)

---

<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:** [September 8, 2024, 1:10am UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/12 "2024-09-08T01:10:00Z")

</div>

Most curious! Clearly something is wrong when two rectangular nodes are not rectangular.

- what OS are you using?
- what version of Graphviz? type `dot -V`

My best guess (and I do mean guess) is that it is somehow related to the uncommon structure of individual nodes within their own subgraphs. (Legal, but not often used). What result do you get with this version of your first file?

```auto
graph ER {
      graph [fontname="pinghei, pingfang sc, microsoft yahei, arial, helvetica, sans-serif"]
      node [fontname="pinghei, pingfang sc, microsoft yahei, arial, helvetica, sans-serif"]
      edge [fontname="pinghei, pingfang sc, microsoft yahei, arial, helvetica, sans-serif"]

  layout=circo;
      overlap = false;

  node [shape="rectangle", style="solid", color="black" label="abbreviation", fontcolor="black"] abbreviation;
  node [shape="ellipse", style="solid", color="red" label="abridgement", fontcolor="red"] abbreviation_abridgement;
  abbreviation_abridgement -- abbreviation;
  node [shape="ellipse", style="solid", color="red" label="digest", fontcolor="red"] abbreviation_digest;
  abbreviation_digest -- abbreviation;
  node [shape="ellipse", style="solid", color="red" label="reduction", fontcolor="red"] abbreviation_reduction;
  abbreviation_reduction -- abbreviation;
  node [shape="ellipse", style="solid", color="red" label="symbol", fontcolor="red"] abbreviation_symbol;
  abbreviation_symbol -- abbreviation;
  node [shape="ellipse", style="solid", color="#0d3b66" label="enlargement", fontcolor="#0d3b66"] abbreviation_enlargement;
  abbreviation_enlargement -- abbreviation;
  node [shape="ellipse", style="solid", color="#0d3b66" label="extension", fontcolor="#0d3b66"] abbreviation_extension;
  abbreviation_extension -- abbreviation;
  node [shape="ellipse", style="solid", color="#0d3b66" label="expansion", fontcolor="#0d3b66"] abbreviation_expansion;
  abbreviation_expansion -- abbreviation;
  node [shape="ellipse", style="solid", color="#0d3b66" label="increase", fontcolor="#0d3b66"] abbreviation_increase;
  abbreviation_increase -- abbreviation;

  fontsize=20;
}

```

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 8, 2024, 6:04am UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/13 "2024-09-08T06:04:30Z")

</div>

Here is the version am using. It seems the latest version of graphviz. I am using my laptop with windows 11.

C:\Users\>dot -V  
dot - graphviz version 12.1.0 (20240811.2233)

 ![my-system](https://global.discourse-cdn.com/graphviz/original/2X/b/b0f5d1f3f3c03ce72b024ec2abbdbd8b45f3e339.png)

The graphs in my previous post were the results by the two dot files (i.e., dot-file-1.txt and dot-file-2.txt).

Josh  
925-895-8351

---

<div class="post-metadata">

**Author:** ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)\
**Post date:** [September 8, 2024, 12:08pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/14 "2024-09-08T12:08:28Z")

</div>

Is the goal to make snowflake-ish layouts and to control the angular order of nodes?

Although this seems quite reasonable, I’m not sure we specifically considered it before. It’s a kind of radial tree layout. As other topics have highlighted, this is an area of Graphviz that isn’t well developed.

---

<div class="post-metadata">

**Author:** ![jianhua.sf](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jianhua.sf](https://forum.graphviz.org/u/jianhua.sf)\
**Post date:** [September 8, 2024, 1:19pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/15 "2024-09-08T13:19:49Z")

</div>

Okay. I may use another engine such as twopi. It produces nice graphs. In addition, it is really good if I could control or specify the edge length, or the overall size of the graph, and at the same time the font should be readable. I have some graphs with a handful of nodes, which stretch out a bit more with long edges.

Come back to my previous issue, how could I fix the issue of “rectangle” of the root node. The root node seems to follow the shape of immediate child nodes.

Josh

---

<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:** [September 8, 2024, 5:54pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/16 "2024-09-08T17:54:17Z")

</div>

Please try the input file I posted above. It might solve the “wrong node shape” problem.

---

<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:** [September 9, 2024, 3:34pm UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/17 "2024-09-09T15:34:02Z")

</div>

Also, please create a bug report [here](https://gitlab.com/graphviz/graphviz/-/issues/) describing the “non-rectangular node” bug.

---

<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:** [September 23, 2024, 12:29am UTC](https://forum.graphviz.org/t/how-to-make-child-nodes-not-interweaved/2429/18 "2024-09-23T00:29:06Z")

</div>

I have enhanced a radial layout engine to now support multiple centers. The updated announcement is [here](https://forum.graphviz.org/t/a-radial-graphviz-engine-pre-processor/1271/3)
