I’ve been banging my head trying to find something that works. The problem comes from duplicated labels which I’d like to use. I’ve played with the ordering param, but it doesn’t help for this use case unfortunately.
I understand the “starting” problem that node labels have to be unique. I am not sure if that is the only problem you are encountering, so let’s go forward.
Do you want a naming scheme that has “meaning”, and if so how much meaning?
We could use random words to name the nodes (e.g. betty, bob, ball, broom, …) [cute, but a pain to implement if the graph gets to be of any size]
Or, a scheme that identifies row (rank) and position within that row (e.g. a1, b1, b2, c1, c2, c3, …) [this seems pretty easy to use, but the “meaning” is not obvious]
Or a scheme that is based on “heritage” with each name showing its parents (e.g. 3, 3_2, 3_1, 3_2_1a, 3_2_1b, …) [OK, maybe not exactly a great scheme, but something to indicate the parentage]
All-in-all I like the second scheme
Are there other problems, maybe with layout?
Here is scheme #2, created manually.
Note that this syntax a1 -> {b1 b2} is not mandatory, but it helps me visualize the binary tree structure as I wrote the input:
Not to state the obvious, but isn’t this inevitable? Fibonacci is a recursive algorithm that results in numerous duplicate calls. I would assume if you want to graph something like this, you would programmatically generate the graph.
Thanks @steveroush! I like your method it’s very easy to follow.
I’ve been having trouble with a recursive algorithm so I thought I’d try to use graphiz to sketch out my thinking.
I took the Fibonacci sequence as an example, because if I reckoned if I could sketch it out easily, then I would be able to construct more complicated graphs.
That’s basically what I wanted to draw (though I’m not sure my thinking is 100% correct here)
Ah I see. To complete my thought and in case it helps your thinking, here is something that I believe implements fibonacci while also printing the Graphviz spec you want:
I thought there was a “todo” entry for trees, but can’t find any open issue for a tree layout engine / pre-processor / language add-on.
It strikes me (naively) that the hardest part is the requirements.
Anybody want to have a go at creating an issue?