Respect the leaf order (chomsky tree alike))

hello graphwizards,

I have this dotfile in my repo. the idea is to describe a grammar in a chomsky tree way. I tested 2 strategies but none of them looks good. As the final output will be a part of a research paper, we have to make it looking good. I consider writing a wrapper over pic to do so but I’d really love to keep it the graphviz way.

Anyone can help on it ?

// Ideal case should be
// digraph {
// 	{ node [shape=plain] rank=same
// 		Alain conduit la voiture
// 	}
// 	nc[label="nom\ncommun"]
// 	sujet      -> Alain
// 	verbe      -> conduit
// 	article    -> la
// 	nc         -> voiture
// 	complement -> {article nc}
// 	phrase     -> { rank=same; sujet verbe complement }
// }
// but rank=same doesn't guaranty the order and this seems to be
// a known possible improvement:
// https://forum.graphviz.org/t/how-to-arrange-node-in-order/1303/2

// so I used record but there are 2 drawbacks
// * the tree isn't a tree anymore. I mean: in the first version,
//   edges where vertical, this looks very good. Not anymore with
//   the record because graphviz lost the ability to position the
//   nodes to do so.
// * I would like to get a grid of the record boxes

digraph {
	texte[shape=record,label="<s>Alain|<v>conduit|<a>la|<nc>voiture"]
	nc[label="nom\ncommun"]
	sujet      -> texte:s
	verbe      -> texte:v
	article    -> texte:a
	nc         -> texte:nc:n
	complement -> {article nc}
	phrase     -> { rank=same; sujet verbe complement }
}

Unfortunately keeping nodes (usually on a shared rank) in the desired order is a common problem. (Help needed: Can't keep nodes in order entered (#1569) · Issues · graphviz / graphviz · GitLab)
There seems to be no guaranteed solution.
Invisible edges & reordering the sequence of the input frequently help.
Does this produce the desired output?

// Ideal case with some modification
 digraph {
 	{ node [shape=plain] rank=same
 		Alain conduit la voiture
 	}
 	nc[label="nom\ncommun"]
 	sujet      -> Alain
 	verbe      -> conduit
 	article    -> la
 	nc         -> voiture
 	complement -> { rank=same nc article}
 	phrase     -> { rank=same; sujet verbe complement }  // added rank=same
	article -> nc  [style=invis]                         // added
 } 

Giving:
chomsky2

Dear steveroush,

a common problem. (Help needed: Can’t keep nodes in order entered (#1569)

The bug ID will help me to stay tunned on it. thank you.

There seems to be no guaranteed solution.

But a perfectly working one in my case.

Invisible edges & reordering the sequence of the input frequently help.

I tried to reorder without luck but haven’t thought about invis edges.
Again: thank you so much for your help!

regards.
marc