Closed noriakis closed 8 months ago
An alternative approach to bundle_strength
which I have used when I ported edge path bundling over to ggraph is to use the same tension
approach used in hierarchical edge bundling. It works by moving the control points of the b-spline closer to the direct line (original edge)
Thank you very much for the insights! I am glad to hear that the edge bundling is now available in ggraph
. I don't know if the pull request here should be modified to use the alternative approach, but I'm ready to implement it.
I'll leave that up to David - just sharing an alternative approach to loosening the bundles
Come to think of it, the relaxation I have might be the inverse of what your parameter adds, right. Your subdivision will make the edges run closer to the shortest path, not farther from it
Thank you for the reply. Yes, the bundle_strength
parameter will make the edge closer to the shortest paths, and takes long time if the strength is high.
library(igraph)
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
library(ggraph)
#> Loading required package: ggplot2
library(patchwork)
library(edgebundle)
# simple edge-path bundling example from README
g <- graph_from_edgelist(matrix(c(1, 2, 1, 6, 1, 4, 2, 3, 3, 4, 4, 5, 5, 6),
ncol = 2, byrow = TRUE), FALSE)
xy <- cbind(c(0, 10, 25, 40, 50, 50), c(0, 15, 25, 15, 0, -10))
res <- edge_bundle_path(g, xy, bundle_strength=1)
res5 <- edge_bundle_path(g, xy, bundle_strength=5)
bs1 <- ggplot() +
geom_path(data = res, aes(x, y, group = group)) +
geom_point(data = as.data.frame(xy), aes(V1, V2), size = 3) +
theme_void() + ggtitle("bundle_strength = 1")
bs5 <- ggplot() +
geom_path(data = res5, aes(x, y, group = group)) +
geom_point(data = as.data.frame(xy), aes(V1, V2), size = 3) +
theme_void() + ggtitle("bundle_strength = 5")
t05 <- ggraph(g, layout="manual", x=xy[,1], y=xy[,2]) +
geom_edge_bundle_path(tension=0.5) +
geom_point(data = as.data.frame(xy), aes(V1, V2), size = 3) +
theme_void() + ggtitle("tension = 0.5")
t1 <- ggraph(g, layout="manual", x=xy[,1], y=xy[,2]) +
geom_edge_bundle_path(tension=1) +
geom_point(data = as.data.frame(xy), aes(V1, V2), size = 3) +
theme_void() + ggtitle("tension = 1")
wrap_plots(list(bs1, bs5, t05, t1))
Created on 2024-01-17 with reprex v2.1.0
@noriakis I will leave it as is, I think. If you want to change it though, go ahead, otherwise I will merge this in the next few days. I think in the long run, I will not put too much work in this package anymore, now that the most important algorithms are migrating to ggraph.
@schochastics Thank you for your reply, and I apologize for the delayed response. I would be grateful if you could proceed with merging in its current form. I will try to implement the feature suggested by @thomasp85 anyway. Thank you again for developing this important package.
Ok will merge this soon. Thanks again for implementing it.
Thank you very much for merging!
Thank you very much for developing this useful library. I have made following changes to the
edge_bundle_path
function and thought if it could be merged for the general use.bundle_strength
argument Implemenation of the original JS function (subdivide
) that controls the strength of bundling.mode
argument The argument to be passed toigraph::shortest_paths
function. Currently themode
parameter will be fixed toout
and I thought it would be useful to pass this parameter arbitrarily, such asall
.I would be grateful if you could review this pull request.