Skip to content

fix(routing): let the cost-matrix functions take one vertex set - #824

Open
MathiasVDA wants to merge 2 commits into
mainfrom
claude/project-thread-es9gu3-817
Open

MathiasVDA wants to merge 2 commits into
mainfrom
claude/project-thread-es9gu3-817

Conversation

@MathiasVDA

Copy link
Copy Markdown
Contributor

Requested by Mathias · project thread

Closes #817

What

pgr_dijkstraCostMatrix and the other *CostMatrix forms (aStar, bdDijkstra, bdAstar, withPoints) take one vertex set, as pgRouting's pgr_dijkstraCostMatrix(edges, vids) does. With only pgr:start_vids, the ends are the starts, so the call answers every ordered pair of different vertices. Before, it failed with pgr: missing pgr:end_vid. The two-set form is unchanged, and pgr_dijkstraCost without ends still fails.

Tests

  • cost_matrices_take_one_vertex_set (crates/tripletrail/tests/sparql.rs): dijkstra, bdDijkstra and withPoints cost matrices with one set give the same rows as with the set given as ends too, and no row from a vertex to itself.
  • A new guide section, "Distances between several stations", in docs/guide/05-routing.md, run by cargo test -p tripletrail-server --test guide.

Docs

docs/routing.md, the routing chapter of the guide, CHANGELOG (Unreleased, Fixed).

Checks

cargo fmt --check, cargo clippy -p tripletrail-pgr -p tripletrail --all-targets -- -D warnings, cargo test -p tripletrail --test sparql cost_matrices, cargo test -p tripletrail-pgr, cargo test -p tripletrail-server --test guide.


Generated by Claude Code

pgr_dijkstraCostMatrix and the other *CostMatrix forms take the
pgr:start_vid set as the ends when no pgr:end_vid is given, as
pgRouting's pgr_dijkstraCostMatrix(edges, vids) does.

Closes #817
@MathiasVDA MathiasVDA self-assigned this Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The audit failure is not caused by this PR. cargo audit finds RUSTSEC-2026-0628 in calamine 0.38.0, an advisory published 2026-11-24. That calamine version is on main too, where audit fails the same way (cab0f26). #828 bumps calamine to 0.39. This PR changes no dependency, so audit should pass here once #828 merges and main is merged in.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Review (Reviewer 2), round 1 at cfcf97d: approved, waits for #828

  • With only pgr:start_vids a *CostMatrix function uses the starts as ends, as pgRouting's one-set form does. The two-set form is unchanged and pgr_dijkstraCost without ends still answers missing pgr:end_vid (tested).
  • cost_matrices_take_one_vertex_set compares one set against the same set given twice for the dijkstra, bdDijkstra and withPoints matrices, and checks that no row goes from a vertex to itself.
  • Docs: docs/routing.md, a tested guide section in chapter 5 with its summary line, and the CHANGELOG.

audit is red here for the reason it is red on main (a new advisory on a dependency, fixed by #828), not because of this change. Once #828 is merged, please merge main into this branch (no rebase); I merge on green after that.


Generated by Claude Code

@MathiasVDA MathiasVDA added the review:approved Reviewer approved label Dec 3, 2026 — with Claude

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

review:approved Reviewer approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(routing): pgr_dijkstraCostMatrix takes one vertex set, without pgr:end_vid

1 participant