Closed treardon17 closed 2 years ago
This issue has been automatically marked as stale, because it has not had activity within the past 30 days. It will be closed if no further activity occurs within the next 30 days. If a feature request is important to you, please consider making a pull request. Thank you for your contributions.
Does Dagre have guarantees, i.e. explicit API documentation, that the ordering of the elements affects the end result?
@maxkfranz dagre itself doesn't have explicit documentation, but dagre uses graphlib
, and graphlib
has documentation for the order of nodes: https://github.com/dagrejs/graphlib/wiki/API-Reference#graph-concepts.
From the graphlib
docs:
directed: set to true to get a directed graph and false to get an undirected graph. An undirected graph does not treat the order of nodes in an edge as significant. In other words, g.edge("a", "b") === g.edge("b", "a") for an undirected graph. Default: true.
cytoscape dagre uses the default value for directed
here, so the order of the nodes are significant.
Great.
What could we do to clarify how this proposed sorting feature would affect the resultant layout, especially for people who are reading the documentation for the first time? The circle layout and grid layout have conventional orderings, clockwise and the Western reading direction respectively (also the typical x/y graphics axes in CS). The natural ordering of a tree is the topology, so the reader can't necessarily make a connection for what sorting would do.
We could clarify in the docs that by default cycoscape dagre creates a directed graph, and directed graphs use the node order as a tie breaker when defining the topology of a graph. This feature is most useful when adding and removing the same nodes and edges multiple times in a graph.
Would that make sense?
Sounds good
On Sep 21, 2022, at 22:47, Tyler @.***> wrote:
We could clarify in the docs that by default cycoscape dagre creates a directed graph, and directed graphs use the node order as a tie breaker when defining the topology of a graph. This feature is most useful when adding and removing the same nodes and edges multiple times in a graph.
Would that make sense?
— Reply to this email directly, view it on GitHub https://github.com/cytoscape/cytoscape.js-dagre/pull/100#issuecomment-1254447306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHRO42NKU7RSI3XU3MRI73V7PCCZANCNFSM6AAAAAAQC2SFJI. You are receiving this because you were mentioned.
@maxkfranz I updated the readme based on what we talked about 👍
Great, @treardon17. I'll set aside some time tomorrow for a merge & release
Sorry, this slipped past me somehow.
Released to npm with your updates for 2.5.0
Thanks @maxkfranz!
Some of the default layouts in cytoscape have a
sort
option (or some variation of it) that lets you sort the nodes/edges so the resulting graph is predictable if you're adding/removing nodes.examples layouts with sort: https://js.cytoscape.org/#layouts/grid https://js.cytoscape.org/#layouts/circle https://js.cytoscape.org/#layouts/breadthfirst
Without this, the graph will have a different outcome if several nodes/edges are added, then some middle nodes/edges are removed, and then those same removed nodes/edges are added back.