I want to the children are positioned the centre of two parents TreeLayout

i want to change

when initialing diagram…
i try to change TreeLayout.alignment,but not working.

That graph is not tree-structured, so I think it is unreasonable to expect TreeLayout to do what you want.

Try using LayeredDigraphLayout instead, although even then you will not be able to ensure nodes are lined up perfectly. Furthermore you will not be easily able to control the order of nodes within a layer.

ok.i will try your advice . Thanks.

@walter if i use LayeredDigraphLayout,how can i obtain the node level like findTreeLevel() in TreeLayout.

The layer number is available as the LayeredDigraphVertex.layer property on each LayoutVertex.

You can override LayeredDigraphLayout.commitLayout to call the base method and then look at any LayeredDigraphVertex that you care about in the LayeredDigraphLayout.network. Note that LayeredDigraphLayout tends to have a lot of “dummy” vertexes – ones that do not have corresponding Node: LayoutVertex.node may be null.