tgdwyer / WebCola

Javascript constraint-based graph layout
http://marvl.infotech.monash.edu/webcola/
MIT License
2.03k stars 258 forks source link

GridRouter.routeEdges outputs reversed paths? #327

Open alexzherdev opened 2 years ago

alexzherdev commented 2 years ago

I'm running into unexpected results when calling routeEdges and am trying to understand whether it works as expected or not. When called on a simple but particular graph layout, one of the edges returned from routeEdges is directed the wrong way (from target to source). One thing I can see that sets this particular edge apart is that its segments have their .i properties reversed:

0: (2) [{…}, {…}, edgeid: 0, i: 1]
1: (2) [{…}, {…}, edgeid: 0, i: 0]

Debugging through the code, this is the only edge that gets .reversed set to true in orderEdges, so while it starts off correct, it later gets incorrectly reversed in unreverseEdges.

I did see this comment in the code:

// warning: edge paths may be reversed such that common paths are ordered consistently within bundles!

Is that what's happening? If so, should I unreverse the edge myself based on the .i values? I looked through examples invoking routeEdges but none of them take this into account.