Skip to content

Reinstantiate 'Distance' type for template expansion. - #575

Merged
Becheler merged 5 commits into
boostorg:developfrom
ascherer:develop
Aug 31, 2026
Merged

Reinstantiate 'Distance' type for template expansion.#575
Becheler merged 5 commits into
boostorg:developfrom
ascherer:develop

Conversation

@ascherer

Copy link
Copy Markdown
Contributor

Before submitting

  • This PR targets the develop branch.
  • I searched for an existing PR or issue covering the same change.
  • My contribution is licensed under the Boost Software License 1.0.

Type of change

  • Bug fix
  • New feature or API addition
  • Refactor (no behavior change)
  • Documentation
  • Build, CI, or tooling
  • Other (specify below)

Does this PR introduce a breaking change?

  • Yes (describe migration impact below)
  • No

What this PR does

It fixes the example program miles_span.cpp for compilation.

Motivation

Recently I upgraded the PROTOTYPES changefiles for The Stanford GraphBase (see https://github.com/ascherer/sgb/releases/tag/2025-12-28; with the grace of Donald Knuth, see https://www-cs-faculty.stanford.edu/~knuth/sgb.html) and now I tried to compile the four SGB example codes girth.cpp, miles_span.cpp, roget_components.cpp, and topo-sort-with-sgb.cpp with g++ 13.3.0 on Kubuntu 24.04LTS.

Testing

andreas@TravelMate .../Extern/graph/example develop
$ g++  miles_span.cpp -I /usr/include/sgb -L /usr/lib/x86_64-linux-gnu/sgb -lgb
andreas@TravelMate .../Extern/graph/example develop ?1
$ ./a.out 
The graph miles(100,0,0,0,0,10,0) has 405 edges,
  and its minimum spanning tree has length 14467.
andreas@TravelMate .../Extern/graph/example develop ?1
$ cat miles_span.expected 
The graph miles(100,0,0,0,0,10,0) has 405 edges,
  and its minimum spanning tree has length 14467

Checklist

  • Existing tests pass (b2 in the test/ directory).
  • New behavior is covered by a test, or this is a docs / build / refactor change.
  • Documentation was updated if user-facing behavior changed.
  • No new compiler warnings on the platforms I built against.

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 33382344232 vs develop run 33382344232 (4015effa5e).

Header-inclusion weights (graph files pulling each direct dependency in):

No header-inclusion-weight changes.

Transitive Boost modules: 66 → 66 (0)

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 33382344207 vs develop run 33382344207 (4015effa5e).

Job Baseline After Delta
macos (clang, 14) 647 647 0
macos (clang, 17) 610 610 0
macos (clang, 20) 610 610 0
ubuntu (clang-19, 14) 647 647 0
ubuntu (clang-19, 17) 610 610 0
ubuntu (clang-19, 20) 610 610 0
ubuntu (clang-19, 23) 610 610 0
ubuntu (gcc-14, 14) 795 795 0
ubuntu (gcc-14, 17) 931 931 0
ubuntu (gcc-14, 20) 931 931 0
ubuntu (gcc-14, 23) 931 931 0
windows_msvc_14_3 (msvc-14.3) 952 952 0

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

@Becheler

Copy link
Copy Markdown
Collaborator

Thank you @ascherer !

Looks like an old commit in 2016 (f4d50aa) was trying to modernize examples with auto but this introduced the bug you solved. Given that /examples folder is not build in CI (and we could probably not easily build this one given its dep on SGB) it's not too surprising the bug remained for so long. Thanks for fixing it !

I am still not sure what to do with the examples folder. @ascherer would you mind telling us how you ended up discovering the file, how you would have prefered to discover it ?

Just for context so we do a better job with those examples! 😄

@ascherer

Copy link
Copy Markdown
Contributor Author

In 1994 I bought Knuth's book "The Stanford GraphBase" and earned my first "bug check" for porting the SGB software to the Commodore Amiga.

In the early 2000s I met Jeremy Siek at the Net.ObjectDays conference in Erfurt and we talked in depth about the SGB interface of the Boost Graph Library. This resulted in the improved #include structure:

// Thanks to Andreas Scherer for numerous suggestions and fixes!

And from time to time (every decade or so), while still working on my PROTOTYPES changefiles of SGB, I remember to check the four BGL examples.

Recently I managed to upgrade my SGB codebase to genuinely compile with C++23 compilers, so today I checked that the SGB header files included in stanford_graph.hpp are still valid.

@ascherer

ascherer commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

I must have met Jeremy at the very first Net.ObjectDays conference in Oktober 2000, where he gave a talk at the C++ template workshop, because of his commit in November 2000: fac92e1

@Becheler Becheler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a small feedback, not mandatory though 👍🏽

Comment thread example/miles_span.cpp Outdated
// Use the "w" property for parent
auto p = get(w_property< Vertex* >(), g);
total_length_visitor< Distance > length_vis(sp_length, d);
total_length_visitor<

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If necessary I do prefer using an explicit type alias to limit complexity of signatures.

using Distance = typename property_map< Graph*, z_property< long > >::type;
total_length_visitor< Distance > length_vis(sp_length, d);

@Becheler

Copy link
Copy Markdown
Collaborator

That's amazing context thank you ! 😄
So you have been around since the early days of BGL ! Impressive !
What is your take about the way BGL could document the SGB interface ? I am not too familiar with its usage so I am unsure what users would need to read in the documentation ?
Anyway thank you for your contributions ! 🚀

@ascherer

Copy link
Copy Markdown
Contributor Author

What is your take about the way BGL could document the SGB interface ?

In older versions of boost::graph there was a dedicated page for the sgb/bgl interface: https://www.boost.org/doc/libs/1_34_0/libs/graph/doc/stanford_graph.html

Later versions don't seem to have this.

In section Installing the SGB I would suggest to point to https://github.com/ascherer/sgb/releases/tag/2025-12-28 and the "local" branch with the latest modifications of the Stanford GraphBase.

@Becheler

Copy link
Copy Markdown
Collaborator

The CI failing in unrelated to you changes (well, examples are not even in CI, I should fix that at some point). I will merge it, and I will open a documentation PR to reinstate the previous state 😄
thanks again!

@Becheler
Becheler merged commit 7779e11 into boostorg:develop Aug 31, 2026
31 of 32 checks passed
@Becheler Becheler self-assigned this Aug 31, 2026
@Becheler Becheler added the docs label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants