I am currently using the Python API. Above is my current graph.
The black nodes shown below are the original nodes. However, after adding the red nodes as shown below, it resulted in the graph above. In other words, how can I add the red nodes shown in the graph below while retaining the hierarchy in the second cluster by aligning the nodes to the top within the second layer?
It is very difficult to debug/change a program without access to the source.
That said, I will take a wild guess at what you want to do - look at the TBbalance attribute (TBbalance | Graphviz)
If that does not solve your problem, please provide source. If you can’t share proprietary information, we can provide an anonymizer program.
Is this a one-time graph (quick & dirty solution is probably OK) or a run-many-times graph (really want to automate completely?)
p.s. if you want to try creating an anonymous version to share, here is a link to an anonymizer GVPR program (cmd/gvpr/lib/anon · main · graphviz / graphviz · GitLab)
download it, produce a dot format output from your Python program (names myFile.gv) and use this command line gvpr -f anon myFile.gv. Note that you may need to hand-edit the cluster names.
Link to GVPR - part of the Graphviz package -(https://www.graphviz.org/pdf/gvpr.1.pdf)
Just making guesses about the input …
There are 3 edges from nodes in the next-to-lowest rank (row) of the middle cluster to nodes in the top rank of the bottom cluster. Add minlen=2 to these edges (minlen | Graphviz). That should push the bottom cluster down, and (with luck) then underneath the middle cluster.