Skip to content

Rename DigraphDijkstra to DigraphShortestPaths - #958

Open
William-Kenyon wants to merge 7 commits into
digraphs:mainfrom
William-Kenyon:fix-issue-570
Open

William-Kenyon wants to merge 7 commits into
digraphs:mainfrom
William-Kenyon:fix-issue-570

Conversation

@William-Kenyon

Copy link
Copy Markdown
Collaborator

Fixes #570, renaming DigraphDijkstra to DigraphShortestPaths, using the new DIGRAPHS_DeclareObsoleteSynonym.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (7c00ce7) to head (a7684f7).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #958      +/-   ##
==========================================
+ Coverage   97.48%   97.49%   +0.01%     
==========================================
  Files          53       53              
  Lines       21363    21478     +115     
  Branches      639      638       -1     
==========================================
+ Hits        20825    20940     +115     
- Misses        473      474       +1     
+ Partials       65       64       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@William-Kenyon William-Kenyon added the VIP Pull requests done by participants of the VIP programme. label Oct 15, 2026

@james-d-mitchell james-d-mitchell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtorpey can you please have a look at this.

My initial reaction is that I'm not sure this addresses #570. In particular, if there's duplicate code between DigraphDijkstra and DigraphShortestPath, then this PR does not remove it. Also if we merge this PR, there will be two functions DigraphShortestPath and DigraphShortestPaths which return two rather different outputs. Also it's not completely clear to me that DigraphShortestPaths is an entirely accurate name, given that it does not return all shortest paths from source to target as the name suggests.

Maybe I'm missing something essential, @William-Kenyon if there's context or rationale behind these changes that I'm missing, then please do let me know!

@William-Kenyon

Copy link
Copy Markdown
Collaborator Author

@james-d-mitchell My renaming follows existing convention: we already have EdgeWeightedDigraphShortestPaths, which returns similar lists of distances and predecessors, and EdgeWeightedDigraphShortestPath which returns in the DigraphPath form. I agree that the wording "paths" is ambiguous, as a user might expect all shortest paths between a source and target, but this could be added in the future under the overload: ...ShortestPaths(digraph, source, target).

The current use of the target parameter is actually as an early exit condition and is not needed anymore, I'll remove it.

As for duplication, DigraphShortestPath uses a BFS, which is slightly faster than DigraphShortestPaths's dijkstras, which is why I didn't refactor them. I realise now however that DigraphShortestPaths is obsolete when its EdgeWeighted... counterpart exists, so I'll make it unweighted and share the BFS of DigraphShortestPath.

@William-Kenyon
William-Kenyon marked this pull request as draft November 10, 2026 15:45
@mtorpey

mtorpey commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

I'm happy with the rename, but @William-Kenyon mentions in his last comment some changes that he'll make to use the weighted version as a helper, which I think would be worth doing.

@William-Kenyon

Copy link
Copy Markdown
Collaborator Author

To match EdgeWeightedDigraphShortestPath's behaviour, I updated DigraphShortestPath to return fail if the source and target vertex are the same. The original behaviour of DigraphShortestPath was to return the shortest non-trivial cycle, if it existed, which to me is unexpected. I'm not sure if this is too big a change, it doesn't break any tests, but some users might rely on the old behavoiur.

@William-Kenyon
William-Kenyon marked this pull request as ready for review November 14, 2026 22:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

VIP Pull requests done by participants of the VIP programme.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename DigraphDijkstra

3 participants