-
Notifications
You must be signed in to change notification settings - Fork 684
Possible to get sankey to handle networks with cycles? #1
Comments
I'd love to see this implemented. The strategy I'd try first is to ignore links that generate cycles in the initial layout, and then add them back in again to draw the loops. |
I'm on it. Any pointers to where I should focus in the code? When I halted it a few times, it was cycling through computeNodeBreadths(), but maybe that was a red herring... |
Right, computeNodeBreadths is where you'll get an infinite loop unless you detect cycles. So that's the first thing (where you ignore links that generate cycles). The second thing is we probably need to handle loopback links and render them differently. Loopback links still exit the right side, but then they need to loopback to the source and enter on the left side. Probably the sankey.link implementation needs to special-case loopback links and generate a different path for them. |
Thanks for the continued conversation. What I did for the short term (because I got users waiting for sankeys, and their networks are acyclic) is cheat. I already got code to detect cycles in python (where I'm assembling the data for the sankeys), so I just disabled the sankeys if your network has a cycle. Then I gotta get my head back on straight within computeNodeBreadths, which currently makes it spin. Then figure out how detect and postpone cyclic links there. I suspect the loopback links are gonna be beyond my skill level, but we'll see. |
I've made an attempt at solving this issue. There are a few ways it could be improved, but please let me know if a pull request (or otherwise) is in order. Example at : http://bl.ocks.org/3921009 Fork and changes at: |
Thanks, but those changes did not work for me. Created false cycles in networks that did not have cycles, and did not handle simple cycles very well. Here's a network that has no cycles, before: Here it is after: Here's one with a cycle, using your changes: Here's the page source: Let me know if you think I did not use your changed code correctly - or if you can't access those files. |
Regarding the first network featuring "Groundfish": Regarding the second network, featuring "Restaurant -> Compost Materials": |
I understand the problem. My code actually assembles the link relationships on the server, so you can't see from the page source how it's done (looking up the array indices based on object identity). I've meant to work up a rev for sankeys to assemble the links based on node object ids rather than array indices in the sankey javascript, but haven't had time. That would at least make explicit what is happening. So if providing unique node ids would help what you are trying to do, I can easily provide them. The duplicate names were a given (to me: they were created by users), and they do actually make sense on some level... |
Alright, round two.
Let me know if this seems usable! |
cfergus, thanks for persisting. It's better; does not falsely detect cycles when nodes have the same names. My networks with cycles look a little odd, but it also looks like I will have to change my code to take advantage of your cycle features. I'm in crunch mode on another project, but will try that when I get a chance. |
Hi -- i just sent a pull request that might help (#39) with this. |
hi all! however http://bl.ocks.org/3956043 is broken thanks! |
are cycles now implemented? |
yes, they are, as i could see yesterday |
My bad. I updated my gist to include the modified sankey.js alongside it. The link should work now for http://bl.ocks.org/3956043 |
Yes! Works now. Thank you, Colin. On Thu, Jul 17, 2014 at 3:19 PM, Colin Fergus [email protected]
|
Any chance we can have the lanes going back in the loop (at the top of http://bl.ocks.org/3956043 ) to retain their width? Or to have it toggle-able to retain width or all squeeze down to the same width, as it is now? |
Hi! i´m Just wondering if its is possible to get these cycle-lanes to the bottom of the diagramm? |
Would it be possible to commit the changes proposed here? |
nicee |
Try to use it for cycles for a single node, i.e. the node is pointing back to itself. Is there a reason why it doesn't work or is it just me? |
Hi all, I did another implementation of this: It's simpler/less code compared to the solution of @cfergus, but I think the cycle detection it is more efficient. examples at http://bl.ocks.org/soxofaan/bb6f91d57dc4b6afe91d/cc526b481b1bc59982e9fe511fd97d776da20b95 (don't forget to refresh |
Those are some nice-looking cycles. On Mon, May 18, 2015 at 7:37 PM, Stefaan Lippens [email protected]
|
So far, looks better than my implementation. I dunno what the etiquette would be, but I consider mine to be 'overtaken'. Should I include a link to your version in my readme? Other preferred way to reflect this? |
But, Colin, thanks for being the pioneer! On Tue, May 19, 2015 at 9:14 AM, Colin Fergus [email protected]
|
FYI: I started a friendly (subtree) fork (see #133) of the sankey plugin at https://github.com/soxofaan/d3-plugin-captain-sankey among others I tweaked the cycle support some more: |
Hi Stefaan, in my project we have just too many cycles making the chart difficult to comprehend. How can I move the cycle paths back to the top like Colin's while keeping your core code. |
Taken from http://bl.ocks.org/cfergus/3956043 Referenced in d3.js issue: d3/d3-plugins#1
Folks,
Basically, I want to show how many sessions were steered/switched from one network to the other. TIA! |
@prakashsd You can do this by having multiple nodes that represent A & B at different times (A1, B1, A2, B2). Such a diagram is sometimes called an “alluvial diagram”. If you have further questions, please ask on Stack Overflow or the D3.js Slack; these issues are for bug reports and active feature development. |
Loving the sankey plugin! But apparently it won't handle networks with cycles, for example:
http://locecon.org/clusters/network/8/
Any ideas about how to fix, work around, or otherwise grapple with the problem?
If so, I will happily try them.
If not, I'll tinker a little and see what I can do...
The text was updated successfully, but these errors were encountered: