-
Notifications
You must be signed in to change notification settings - Fork 114
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
Force-Directed Edge Bundling (#267) #356
Conversation
Thanks for this! A couple of inputs:
|
True. Removed
hmm thinking about it, it seems that what is implemented at the moment is actually more like a 0 version. Edges are segmented but without much control for the user since the
That is a different algorithm: http://vis.stanford.edu/papers/divided-edge-bundling. Never got around to implement it. A matlab implementation is on GitHub. An algorithm one could think of including is edge-path bundling, which is similar to force bundling but I think a bit faster. I have it implemented in
Thats a good idea but also out of my comfort zone :) So beyond more cleanup if necessary, I am afraid I cannot contribute more at the moment. Hope it is enough for you to continue. Otherwise we postpone it |
This is already great. I think I can take it from here |
Great, thanks! |
Looking at your edgebundle package there are a bunch of versions that would be interesting to add to ggraph. How would you rather do it? Move over code from your package or import it (potentially requiring some new interfaces in edgebundle)? |
good question. I think the edge-path bundling would be a good candidate to port to ggraph. Stub bundling is buggy and hammer bundling requires datashader from python, so I think both wouldnt make sense to bring to ggraph. In my opinion edge-path and force directed would be enough. Are you also interested in the flow maps and metro layout? |
yeah, I think especially the flow maps would be interesting to bring in, but see no reason to not bring over the metro layout as well while I have somehow now committed to make a feature release 😅 |
I'll add the path bundling to this PR as it is akin in spirit |
Yes the edge path bundling shouldn't be too hard to port. The flow maps would indeed be cool to have in ggraph as well. Not sure how complex it is too move over though. The metro map thing is indeed rather niche and I dont see a point either to make this more widely accessible. |
I've added the edge path version as well. If you have the time can you check I haven't done anything obviously wrong and written anything wrong in the docs about it? |
Also added an extremely simple bundling technique that kinda just popped into my head. Trace the shortest paths on the minimal spanning tree of the graph weighted by edge lengths. I can't claim it leads to visually better output but it is extremely fast |
I had a look. Everything looks good to me |
This PR adds a new geom:
geom_edge_bundle_force()
. It is a reimplementation of the D3 Version and the version that is also available in different form in the package edgebundle. The main working horse is implemented insrc/forceBundle.cpp
.Details
Edge bundling always needs to create a number of intermediate points on an edge. Thus, in my opinion,
the version
geom_edge_bundle_force()
should suffice (no "0" and "2" version needed).The force bundling algorithm is computationally expensive and will run for a while. To prevent repeated calculation (e.g. when aesthetics are changed) memoise was used so that the bundling only needs to be calculated once.
The algorithm has many parameters which, IMO, are not that easy to fine tune, but the defaults are reasonable in most circumstances.
Disclaimer: This is the first time I wrote a custom geom. Not sure I followed all best practices. Happy to make any change necessary.
Examples
Simple Example: No Bundling
Simple Example: With Bundling
US Flight Network
Created on 2024-01-11 with reprex v2.0.2