How to make child nodes not interweaved

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

Will you share your source file?

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                                                       ;
	}

should have made the file attachment.
dot_file.txt (1.7 KB)

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

Attached please find one more layer of node. if modifying the engine to “circo”, you may review the graph
dot_file2.txt (3.8 KB)

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

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

which produces:

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

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.
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.



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.

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

Gives:

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 (4.2 KB)


dot-file-2.txt (1.8 KB)

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?

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;
}

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)

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

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.

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

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

Also, please create a bug report here describing the “non-rectangular node” bug.

I have enhanced a radial layout engine to now support multiple centers. The updated announcement is here