# how to form a pyramid-like layout

Hi guys, I am a new beginner for Graphviz. And i need to generate a triangle layout like a pyramid. Although i tuned a number of parameters for nodes, edges, graphs (e.g., rank, nodesep, minlen, ...), it just did not work in Graphviz as it is now in a "sparse" shape. Could you please give me some ideas how to produce a triangle layout based on the following example? Thank you in advance!

digraph G {

graph[rankdir="BT"]

b->a c->a d->b e->b g->c h1->d h2->d h3->e h7->g

}

But the target layout i want to generate is something like this:

### Could you give a better

Could you give a better description of what you are after? Your graph is not symmetric, so it is unclear how you want the nodes positioned to give you a "pyramid". Thanks.

### a pyramid-like layout

Hi Erg! Yes, it is not symmetric, each layer has one more node than its upper layer.

### Thanks, Erg. I have edited my

Thanks, Erg. I have edited my question and also now give an example of the target layout. Yes, you are right, my graph is not symmetric. In fact, each layer have one more node than its upper layer (from top to bottom). I am really confused why graphviz cannot make it compact a bit automatically as it is now pretty sparse. Do you have any solutions? :-)

### Keep in mind that dot knows

Keep in mind that dot knows nothing about your layers unless you specify them. Otherwise,it uses the edges to do ranking and from your point of view, the graph will be very unsymmetric. Even if you specify the ranks, if the edge structure is not symmetric, dot will try to shorten edges and make the drawing more compact, which is not what you want. If you have strict constraints, you need to encode these in the graph. In your case, you basically want to specify the ranks and add edges to make sure each node is locally symmetric. Any edges that you don't want in the final drawing you can make invisible. Here is a template for such a graph for the first few rows. This will roughly give you the layout you want. You can use all the various parameters (ranksep,nodesep,shape, etc.) to tune the final layout.

digraph {
0
{rank=same 3->4}
{rank=same 6->7->8}
{rank=same 10->11->12->13 13->14 [style=dotted]}
0->1 [style=invis]
0->2
1->3 [style=invis]
1->4
2->4 [style=invis]
2->5
3->6 [style=invis]
3->7 [style=invis]
4->7 [style=invis]
4->8
5->8
5->9 [style=invis]
6->10 [style=invis]
6->11 [style=invis]
7->11 [style=invis]
7->12 [style=invis]
8->12 [style=invis]
8->13
9->13
9->14 [style=dotted]
}

### Thank you so much! It now

Thank you so much! It now works. :-)