[API] Add simplified overloads for algorithms (starting with Dijkstra)
@Becheler is already working on this.
Since Apr 12, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
I am reworking the documentation, and in need of a nice example for the landing page. The most popular algorithm is Dijkstra. However, given that named parameters should be deprecated, illustrating the current API for Dijkstra shortest path algorithm would require full positional argument list and makes the alternative to named parameters rather painful:
dijkstra_shortest_paths(g, vertex(0, g),
make_iterator_property_map(pred.begin(), index),
make_iterator_property_map(dist.begin(), index),
costs,
index,
std::less<int>(),
std::plus<int>(),
std::numeric_limits<int>::max(),
0,
dijkstra_visitor<null_visitor>());
Users expect to write simpler things, like:
dijkstra_shortest_paths(g, s, pred, dist, weight);dijkstra_shortest_paths(g, s, pred, dist, weight, index);with custom index map whenVertexList=listS
Proposal
Add two overloads to cover most use cases. Arity 5 overload should cover 90% of use cases.
Arity 3: (g, s, named_params) // existing, to be dropped
Arity 5: (g, s, pred, dist, weight) // NEW, safe
Arity 6: (g, s, pred, dist, weight, ix) // NEW, safe
Arity 11: (g, s, pred, dist, weight, ix, cmp, combine, inf, zero, vis) // existing
Arity 12: (g, s, pred, dist, weight, ix, cmp, combine, inf, zero, vis, color) // existing
List of candidate algorithms to benefit from a better overload set
| Algorithm | Min positional arity | Proposed min | Saved |
|---|---|---|---|
dijkstra_shortest_paths |
11 | 5 | 6 |
dag_shortest_paths |
11 | 6 | 5 |
bellman_ford_shortest_paths |
8 | 5 | 3 |
astar_search |
14 | 5 | 9 |
prim_minimum_spanning_tree |
7 | 2 | 5 |
johnson_all_pairs_shortest_paths |
5 | 4 | 1 |
breadth_first_search |
5 | 2 | 3 |
depth_first_search |
3 | 1 | 2 |
- Dominant language
- C++
- Stars
- 395
- Forks
- 239
- Avg merge
- 18h 50m
- Merged PRs (30d)
- 20
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/graph
-
beginner friendly
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
algorithm beginner friendly priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
priority: high warning
-
algorithm
boostorg/graph#493 · 22 comments · 1 reaction · 2 assignees ·
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·