Skip to content

V2 examples#28

Merged
pratzl merged 20 commits intomainfrom
v2_examples
May 3, 2026
Merged

V2 examples#28
pratzl merged 20 commits intomainfrom
v2_examples

Conversation

@pratzl
Copy link
Copy Markdown
Collaborator

@pratzl pratzl commented May 3, 2026

No description provided.

Phil Ratzloff and others added 20 commits April 30, 2026 11:16
- Add examples/AdaptingThirdPartyGraph/adapting_a_third_party_graph.cpp:
  graph-v3 refactor of the v2 example; adapts MyGraph via four ADL CPOs
  (vertices, edges, target_id, vertex_value) with no num_vertices override
- Add examples/CMakeLists.txt: adapting_third_party_graph build target
- Extend num_vertices(g) CPO with a tier-3 fallback:
  std::ranges::size(vertices(g)) fires before std::ranges::size(g),
  so any graph providing vertices(g) → sized_range gets num_vertices free
- Update docs to reflect the new four-tier resolution order:
  cpo-reference.md, contributing/cpo-implementation.md,
  user-guide/adjacency-lists.md
- Stage AdaptingThirdPartyGraph/ (root, v2 source) and PageRank/ files
Copies the CppCon 2021 conference examples into examples/CppCon2021/
and refactors them from the v2 API (vertex/edge references) to the
v3 API (descriptors, CPOs).

Key v2 -> v3 changes:
- utilities.hpp: remove graph::basic_adjacency_list constraint (not in
  v3); fix join() to read plain integer edge values directly instead of
  calling graph::target_id CPO
- graphs.cpp: breadth_first_search.hpp -> bfs.hpp; edges_breadth_first_search
  -> edges_bfs with std::size_t seed
- bacon.cpp: sourced_edges_breadth_first_search([u,v,uv]) ->
  edges_bfs([uv]) + source_id/target_id CPOs inside loop
- ospf.cpp: init_shortest_paths now takes graph as first arg;
  dijkstra uses container_value_fn for distance/predecessor; weight
  lambda signature changed to (const G&, const edge_t<G>&)
- imdb.cpp: same BFS and weight-function changes as bacon/ospf;
  kprop becomes a two-argument (g, uv) lambda

CMakeLists: examples/CppCon2021/CMakeLists.txt owns the four targets;
examples/CMakeLists.txt delegates via add_subdirectory(CppCon2021).
- rr_adaptor.hpp: generic range-of-ranges graph adaptor for graph-v3
  - CPO friend functions use descriptor pattern (vertex_descriptor, edge_descriptor)
  - Data members declared before friend functions so trailing return types resolve
  - vertex_value uses decltype(auto) (no trailing return type)
- graphviz_output.hpp: Graphviz .gv output helpers (brace-init fixes MVP)
- germany_routes_example.cpp: builds Germany routes graph, runs Dijkstra
  - uses graph::dijkstra_shortest_paths + init_shortest_paths
  - weight lambda signature: (const G&, const edge_t<G>&) -> W
- CMakeLists.txt: cppcon22_germany_routes target
- examples/CMakeLists.txt: add_subdirectory(CppCon2022)
- docs/examples.md: new landing page covering all examples
  (AdaptingThirdPartyGraph, CppCon2021, CppCon2022, PageRank,
  basic_usage, dijkstra_clrs, mst_usage, bgl_adaptor)
- docs/index.md: add Examples link in For Users section
- docs/getting-started.md: add See also cross-reference to examples page
- CHANGELOG.md: add entries for AdaptingThirdPartyGraph, PageRank,
  CppCon2021, and CppCon2022 examples under [Unreleased]
- Add CMakeLists.txt for BGLWorkshop2026 (C++20, links graph3)
- Register BGLWorkshop2026 subdirectory in examples/CMakeLists.txt
- bacon1(): BFS Bacon numbers on integer-indexed costar adjacency list
- bacon2(): bipartite movie-actor graph using mol_graph_traits (map+list,
  string vertex ids); loads vertices/edges directly via lambdas without
  intermediate vectors; manual BFS for Bacon numbers on map-keyed graph
Relax the vertex-id requirement in BFS, DFS, and topological sort from
index_adjacency_list (integral ids only) to adjacency_list, enabling use
with map/unordered_map-backed graphs whose vertex descriptors are not
reducible to an integer (e.g. std::string keys via uol_graph_traits).

Changes:
- search_base.hpp: visited_tracker now selects storage at compile time:
    * std::vector<bool> bitset for integral / index-based descriptors
    * std::unordered_set<Vertex> for everything else
  Added unmark_visited() to support recursion-stack backtracking.
- bfs.hpp: relax concept to adjacency_list; remove dead target_vid
  locals from both vertices_bfs_view advance methods; update docs.
- dfs.hpp: relax concept to adjacency_list; replace all vertex_id()
  calls in advance loops and seed marking with descriptor-direct calls;
  update docs.
- topological_sort.hpp: relax concept to adjacency_list; convert
  rec_stack_ from std::vector<bool> to visited_tracker<vertex_type>
  (supports non-integral descriptors via hash set); use unmark_visited()
  for backtracking; update docs.
- docs/user-guide/views.md: add Non-Integral Vertex IDs section;
  update supported-graphs notes and memory-usage table for BFS, DFS,
  and topological sort.
- tests: non-integral tests distributed into their matching files
  (test_search_base.cpp, test_bfs.cpp, test_dfs.cpp,
  test_topological_sort.cpp); 78 assertions across 15 test cases.
…bacon2() with enum class

- agents/multi_type_analysis.md: full analysis of 5 options (A-E) for
  multi-partite graphs with per-partition C++ types; Options B/C/D/E
  developed in detail with pros/cons, CPO impact, and bacon4() examples
- examples/BGLWorkshop2026/bacon.cpp:
  - bacon2(): replace variant<movie_v,actor_v> with enum class vertex_kind
  - bacon3(): use mol_graph_traits with variant<monostate,movie,actor> as
    VId (key IS the domain object; vertex value = void)
  - movie/actor moved to file scope with operator<=> and std::hash
  - add using namespace std::string_literals
source_id(g, uv) and target_id(g, uv) now return 'const VId&' for
non-integral vertex id types (e.g. std::string), matching the existing
behaviour of vertex_id(g, u). Integral VId types continue to return
by value as before.

Three-layer fix:
- include/graph/detail/edge_cpo.hpp: _source_id::_fn::operator() changed
  from 'auto' to 'decltype(auto)' so the const-ref from the descriptor
  layer is not stripped by the CPO.
- include/graph/container/dynamic_graph.hpp: dynamic_edge_target::target_id()
  member and its ADL friend changed to 'decltype(auto)' with the same
  integral/non-integral conditional as vertex_descriptor::vertex_id():
  return target_id_ by value for integrals, by (const&) otherwise.
- include/graph/adj_list/edge_descriptor.hpp: edge_descriptor::target_id()
  for is_out_edge changed from 'auto' to 'decltype(auto)' so the const-ref
  from dynamic_edge_target propagates through to the CPO.

examples/BGLWorkshop2026/bacon.cpp: 'vertex_id_t<G>& u_id' corrected to
'const auto& u_id' — the result is const string& not a mutable reference.
- bacon.cpp: wrap bacon1/bacon2/bacon3 in their own namespaces; rename
  functions to run()/load()/eval()/dot() within each namespace.
  Extract bacon2::eval() (BFS from Kevin Bacon, returns graph + depth
  map); bacon2::run() and bacon2::dot() both call eval() eliminating
  duplicated BFS code.  bacon2_load() renamed to bacon2::load().
  Add BGLWS_OUTPUT_DIR compile definition; bacon2::dot() writes to
  examples/BGLWorkshop2026/output/bacon2.dot.
- imdb-graph.hpp: fix double-space typo "Tom  Cruise" -> "Tom Cruise"
  that caused a spurious second vertex with wrong shape in DOT output.
- dot.hpp: emit all vertex declarations before all edges (prevents
  implicit node creation with wrong attributes); replace nested
  vertex/edge loops with views::edgelist(g); use dot_id() consistently
  for both node ids and label attribute values (removes manual quoting).
  Add #include <graph/views/edgelist.hpp>.
- CMakeLists.txt: add BGLWS_OUTPUT_DIR definition; add output/ dir.
- .gitignore: ignore examples/**/output/* but keep .gitkeep.
- examples/BGLWorkshop2026/france_routes.cpp: new Dijkstra example
  using vom_graph_traits (vector+map edges), load_result struct returning
  graph + city_id map, path reconstruction via find_vertex_edge
- examples/BGLWorkshop2026/CMakeLists.txt: add bglws_france_routes target
- examples/BGLWorkshop2026/graphs/: rename france_cities.json -> france_routes.json
- include/graph/container/dynamic_graph.hpp: add ADL friend find_vertex_edge
  to dynamic_vertex_base; uses map::find (O(log n)) for associative edge
  containers, linear scan fallback for sequential containers
Replace write_dot() call with inline emission that writes an
undirected `graph` with `--` edges. Bidirectional actor<->movie
pairs are deduplicated via set<pair<string,string>> with min/max
key, so each edge appears exactly once. Vertex attrs (shape/color/
Bacon-number label) are preserved.

Also add missing <format>, <iomanip>, <set> includes to bacon.cpp
and sort includes alphabetically.
Warning fixes:
- traversal_common.hpp: suppress unused-parameter warnings in
  _null_range_type constructors via [[maybe_unused]] and unnamed params
- dynamic_graph.hpp: name target_id() graph param as unnamed to
  silence -Wunused-parameter
- france_routes.cpp: remove unused `r` variable in path loop
- bacon.cpp: remove unused `using G = graph_t;`

france_routes refactor:
- vid_t changed to size_t (removes static_cast noise)
- add dist_t alias for int distance values
- extract city_name / route_distance / route_road property lambdas
- scope distance/path blocks with { } to limit variable lifetimes
- city_name lambda in dot() takes vertex_t directly (no extra lookup)

Housekeeping:
- delete france_cities_orig.dot (superseded by france_routes.dot)
- update bglws_outline.md with session notes
- Add bacon_bgl.cpp and france_routes_bgl.cpp as BGL counterparts
- Rename bacon.cpp -> bacon_gv3.cpp, france_routes.cpp -> france_routes_gv3.cpp
- Update CMakeLists.txt and workshop outline accordingly
- Add adjacency_list and edge_list concept diagrams (dot/svg)
…ierarchy

- Add adjacency_list_concepts.svg and edge_list_concepts.svg to reference/concepts.md, user-guide/adjacency-lists.md, and user-guide/edge-lists.md
- Fix ASCII concept hierarchy to match adjacency_list_concepts.dot:
  add missing hashable_vertex_id and in_edge_range, correct placement of
  ordered_vertex_edges and bidirectional compound concepts, switch to
  tier-based layout to accurately represent the DAG structure
- Fix rr_adaptor.hpp: move vertices_ data member before friend templates
  to satisfy GCC 15 -Wtemplate-body declaration-order requirement
- Refresh docs/status/coverage.md with 2026-05-03 data (95.6% line /
  92.4% function, 4873 tests passing); add Generators, I/O, Detail,
  Adaptors sections and Changes-Since-Last-Report
- Update docs/status/implementation_matrix.md: add TOC, correct algorithm
  count (14->15, note tarjan_scc umbrella exclusion), fix views count
  (10->8), add Reader return-type column to I/O table, add Edge List /
  Adjacency List Infrastructure / Top-Level Headers sections
- Revise agents/bgl_migration_strategy.md: add review timestamp, reflect
  implemented items (filtered_graph, BGL adaptor, DOT/GraphML/JSON I/O,
  4 generators), fix prim() signature, fix adaptor scorecard (20%->60%),
  refresh roadmap phases to remove completed work
@pratzl pratzl merged commit 0b09077 into main May 3, 2026
11 checks passed
@pratzl pratzl deleted the v2_examples branch May 3, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant