-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
successors() does not return the original order #15
Comments
It's is just coincidence. Try adding a node "12345" before and after node A. In both cases on Chrome it ends up before the node A. There are no guarantees on returned order either for the nodes call or for the successors call right now. |
Hmm, that could be a problem for me, since I need ordering. Would adding it to the nodes() and successors() be all that is needed for ordering to work? |
For the moment you can still do this on your end by either:
However, even if we do get the nodes ordered it may not do what you want. Can you describe your use case in a little more detail. Superficially it sounds like it may benefit from #112. |
When I sort the nodes, how do I tell dagre layout the sort order? For my use case see http://jsfiddle.net/fk2t8/ You can click on the nodes to show/hide the children (except the first child, which is always shown). If you click on the root twice, you'll see the order is all mess up. Clicking on "b", the behavior is exactly what I want. |
Hey, changing successors to
Seems to preserve the order for my use case now. |
There are a couple subtle issues with this approach, but it may be OK for your purposes:
We can get away with better time complexity by maintaining a tree internally, but I need to see what kinds of lookups we're doing to see if that works out in our favor. Also, I meant to reference dagrejs/dagre#112 which I believe would help for your case. |
So putting a order field on the node and edges should be what it takes? Let me try it |
Maybe I'm misunderstanding something but putting an order in the nodes seems to have no effect? http://jsfiddle.net/fk2t8/4/ |
Sorry, the comment about adding your own order does no good for dagre drawing. For that you probably need something like dagrejs/dagre#112. Sorry for causing confusion. |
In the demo at http://cpettitt.github.io/project/dagre-d3/latest/demo/interactive-demo.html
The nodes are rendered with respect to the order the node/links are defined. Eg: if A -> D is defined before A -> B, then D will be to the left of B, and vise versa. So the order is stored in the graph(?)
However, graph.successors() does not seem to return the original order?
The text was updated successfully, but these errors were encountered: