Open
feat: expose widest paths functions as widest_paths() and widest_path_widths()#2408
widest_paths() and widest_path_widths()#2408Conversation
Copilot
AI
changed the title
[WIP] Expose widest paths functions as optional
feat: Expose widest paths functions as Oct 26, 2025
widest_paths() and widest_path_widths()
krlmlr
requested changes
Oct 26, 2025
Member
|
I want to have a careful look at this as I get the time. |
widest_paths() and widest_path_widths()widest_paths() and widest_path_widths()
Contributor
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c176ff7 is merged into main:
|
krlmlr
marked this pull request as ready for review
July 26, 2026 15:04
Flattened onto the current main (post-#2779 rebase); content unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016M32izVHZPfxAqemAe4BrX
krlmlr
force-pushed
the
copilot/expose-widest-paths-functions
branch
from
July 26, 2026 16:43
c176ff7 to
5f7926e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exposes the C widest paths implementation to R users
with two new experimental functions.
Fixes #1566.
API
Both functions follow the argument-zoning policy for new functions:
defining arguments come first,
all modifiers are keyword-only behind
...(guarded by
rlang::check_dots_empty()),and all arguments use
snake_case.widest_path_widths()(analogous todistances())returns the matrix of widest path (bottleneck) widths
between two vertex sets.
With
algorithm = "automatic"(the default),Dijkstra is used for sparse graphs
and Floyd-Warshall for dense graphs.
widest_paths()(analogous toshortest_paths())returns one widest path per target vertex.
outputselects vertex paths, edge paths, or both;predecessorsandinbound_edgesoptionally returnthe widest path tree,
reporting the start vertex and unreached vertices as
NA.Weights requirement
The C implementation requires edge weights (interpreted as widths),
so unlike
distances(), these functions errorwhen no weights are available:
weightedge attribute is used whenweights = NULL;weightattribute,and for
weights = NA.Bug fix required by this feature
create_es()did not forwardna_oktosimple_es_index(),so an edge sequence containing
NAcould not be created,and the cli edge-sequence printer failed on
NAedge IDs.Both are fixed here,
which also repairs
shortest_paths(inbound.edges = TRUE):it previously errored with "Unknown edge selected".
Usage
Tests
tests/testthat/test-aaa-auto.R:snapshot and structured tests for
widest_path_widths_dijkstra_impl()andwidest_path_widths_floyd_warshall_impl(),the two
_impl()functions that had no coverage yet(
get_widest_path_impl()andget_widest_paths_impl()were already covered).
tests/testthat/test-paths.R:structured tests for widths, algorithm equivalence, modes,
vertex names, unreachable vertices, and path/tree outputs,
plus snapshot tests for all error paths
and for printing
NA-containing vertex/edge sequences.