From 5e6e456e5a8e5d86758fccc44d80035f1362f9e2 Mon Sep 17 00:00:00 2001 From: Arnaud Becheler <8360330+Becheler@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:17:15 +0100 Subject: [PATCH 1/2] bug: tiernan_all_cycles rejects adjacency_list --- test/tiernan_all_cycles.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/tiernan_all_cycles.cpp b/test/tiernan_all_cycles.cpp index 3abe0d84f..92ec85f69 100644 --- a/test/tiernan_all_cycles.cpp +++ b/test/tiernan_all_cycles.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -103,6 +104,24 @@ void test_stateful_visitor_with_ref() BOOST_TEST_EQ(copied.count, static_cast< std::size_t >(0)); } +// adjacency_list has a vertex index but no renumber_vertex_indices, see issue 182 +void test_adjacency_list() +{ + using graph_t = boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS >; + graph_t g(4); + + // a triangle and a two cycle, so two elementary cycles + boost::add_edge(0, 1, g); + boost::add_edge(1, 2, g); + boost::add_edge(2, 0, g); + boost::add_edge(1, 3, g); + boost::add_edge(3, 1, g); + + cycle_tally tally; + boost::tiernan_all_cycles(g, std::ref(tally)); + BOOST_TEST_EQ(tally.count, static_cast< std::size_t >(2)); +} + int main(int, char*[]) { typedef undirected_graph<> Graph; @@ -115,6 +134,7 @@ int main(int, char*[]) test< DiGraph >(); test_stateful_visitor_with_ref(); + test_adjacency_list(); return boost::report_errors(); } From 7844c670ac0462cdf72ff80f7b396f7b2ca8edda Mon Sep 17 00:00:00 2001 From: Arnaud Becheler <8360330+Becheler@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:18:14 +0100 Subject: [PATCH 2/2] fix: tiernan_all_cycles requires only a vertex_index map --- include/boost/graph/tiernan_all_cycles.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/graph/tiernan_all_cycles.hpp b/include/boost/graph/tiernan_all_cycles.hpp index 792681b93..aab2d7edd 100644 --- a/include/boost/graph/tiernan_all_cycles.hpp +++ b/include/boost/graph/tiernan_all_cycles.hpp @@ -150,8 +150,9 @@ namespace detail const ClosedMatrix& m) { BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); - BOOST_CONCEPT_ASSERT((VertexIndexGraphConcept< Graph >)); typedef typename graph_traits< Graph >::vertex_descriptor Vertex; + using IndexMap = typename ::boost::property_map< Graph, ::boost::vertex_index_t >::const_type; + BOOST_CONCEPT_ASSERT((::boost::ReadablePropertyMapConcept< IndexMap, Vertex >)); // get the vertices in question Vertex u = source(e, g), v = target(e, g);