Skip to content

Visitor extensions#31

Merged
pratzl merged 5 commits into
mainfrom
visitor_extensions
May 30, 2026
Merged

Visitor extensions#31
pratzl merged 5 commits into
mainfrom
visitor_extensions

Conversation

@pratzl
Copy link
Copy Markdown
Collaborator

@pratzl pratzl commented May 30, 2026

No description provided.

pratzl added 5 commits May 30, 2026 12:55
- Add has_any_visitor_event<G,V> — disjunction of all 19 has_on_* concepts
- Add valid_visitor<G,V> — satisfied by empty_visitor or any visitor with at
  least one recognised on_* callback; rejects structs whose only on_*-like
  methods are misspelled and would otherwise be silently ignored
- Add #include <concepts> and <type_traits> to traversal_common.hpp
- Enforce valid_visitor via static_assert at the top of the implementing body
  of bfs, dfs, dijkstra and bellman_ford; message directs user to the typo
  and the empty_visitor{} escape hatch
- Add compile-time static_assert tests in test_breadth_first_search.cpp
  covering empty_visitor (pass), a correct visitor (pass), and a typo
  visitor (fail)
BGL-style composable visitors built on the existing duck-typed on_* model,
without changing any traversal algorithm.

Layer 1 — single-event adaptors (on_discover_vertex(f), on_tree_edge(f), ...):
  wrap a callable so it fires for exactly one event; analogue of BGL event tags.
  Generated for all 14 event names (5 vertex + 9 edge) via a macro.

Layer 2 — composite_visitor / make_visitor(...): fan one traversal out to many
  sub-visitors. Each event method is constrained by a fold over the child pack,
  so a composite only exposes on_X when a child handles X — keeping has_on_* and
  valid_visitor detection accurate and preserving zero-overhead event skipping.
  Bridges descriptor- and id-form children from a single event via vertex_id().

Layer 3 — prebuilt recorders: predecessor_recorder, distance_recorder (weighted
  + hop-count overloads) and time_stamper. Each returns a plain (g,x)->void
  callable so the caller binds it to any event, e.g.
  on_tree_edge(predecessor_recorder(pred)) for BFS/DFS or
  on_edge_relaxed(predecessor_recorder(pred)) for Dijkstra/Bellman-Ford.

- Register header in graph/algorithms.hpp umbrella
- Add tests/algorithms/test_visitor_factory.cpp (compile-time valid_visitor /
  has_on_* integration checks + runtime BFS/DFS/Dijkstra coverage)
- Wire test file into tests/algorithms/CMakeLists.txt
…tegy.md

visitor_factory.hpp: Add '@Par BGL Comparison' section to the file-level
Doxygen block showing BGL make_bfs_visitor syntax vs. graph-v3 make_visitor,
plus a bullet list of four key design differences.

bgl_migration_strategy.md: Update Section 7 'Visitor Pattern Migration' to
replace the 'Composable Visitor Adaptors — Gap (still open)' subsection with
full documentation of the three-layer toolkit (single-event adaptors,
make_visitor, prebuilt recorders), the BGL vs. graph-v3 syntax comparison,
and a per-recorder event-binding table. Also update the Key Differences table,
Executive Summary gaps list, Phase 3 roadmap table, and 'Done' note. Bump
last-reviewed date to 2026-05-30.
…isitor_factory

Local variable 'edges' at lines 75 and 92 shadowed
graph::adj_list::_cpo_instances::edges (graph_cpo.hpp:816).
Clang on macOS/CI treats -Wshadow as -Werror.
@pratzl pratzl merged commit aea5068 into main May 30, 2026
11 checks passed
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