g <- edgebundle::us_flights
xy <- cbind(
igraph::V(g)$longitude,
igraph::V(g)$latitude
)
p <- vgraph(g, layout = xy) |>
mark_edge_bundle(type = "force", color = "steelblue") |>
mark_nodes(size = 0.2, fill = "orange") |>
labs(title = "US domestic flight routes")Edge bundling
Straight edges on a dense graph overlap into a hairball. mark_edge_bundle() routes them as curves that merge where they run together, so the graph’s backbone shows through. It swaps in for mark_edges() and takes the same edge aesthetics; the geometry comes from the edgebundle package.
The classic demonstration is edgebundle::us_flights: 276 US airports and 2,682 routes between them. Laying the airports out at their real longitude/latitude draws the outline of the country; force bundling then pulls the routes into the transcontinental corridors.
type picks the algorithm. "force" (used here) and "path" bend edges toward their neighbours, "stub" only tufts each endpoint, and "mingle" merges hierarchically; "divided" splits a directed graph’s trunks by direction. Pass algorithm-specific tuning through params. Bundled edges are faint by default, so overlapping trunks read as density.
