Skip to content

Commit daa6f09

Browse files
committed
chore: Migrate 1.4 mcgregor_subgraphs.cpp with range-based for
1 parent de2eed5 commit daa6f09

1 file changed

Lines changed: 17 additions & 34 deletions

File tree

‎test/mcgregor_subgraphs_test.cpp‎

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <boost/lexical_cast.hpp>
1717
#include <boost/random.hpp>
18+
#include <boost/range/iterator_range.hpp>
1819
#include <boost/graph/adjacency_list.hpp>
1920
#include <boost/graph/filtered_graph.hpp>
2021
#include <boost/graph/graphviz.hpp>
@@ -102,8 +103,7 @@ template < typename Graph > struct test_callback
102103
EdgeNameMap ename_map2 = get(boost::edge_name, subgraph2);
103104

104105
// Verify that subgraph1 matches the supplied common subgraph
105-
BGL_FORALL_VERTICES_T(vertex1, subgraph1, MembershipFilteredGraph)
106-
{
106+
for (auto vertex1 : boost::make_iterator_range(vertices(subgraph1))) {
107107

108108
Vertex vertex_common
109109
= vertex(get(vindex_map1, vertex1), m_common_subgraph);
@@ -116,16 +116,13 @@ template < typename Graph > struct test_callback
116116
// Keep looking
117117
return (true);
118118
}
119-
120-
BGL_FORALL_VERTICES_T(vertex1_2, subgraph1, MembershipFilteredGraph)
121-
{
122-
119+
120+
for (auto vertex1_2 : boost::make_iterator_range(vertices(subgraph1))) {
123121
Vertex vertex_common2
124122
= vertex(get(vindex_map1, vertex1_2), m_common_subgraph);
125123
EdgeInfo edge_common
126124
= edge(vertex_common, vertex_common2, m_common_subgraph);
127125
EdgeInfo edge1 = edge(vertex1, vertex1_2, subgraph1);
128-
129126
if ((edge_common.second != edge1.second)
130127
|| ((edge_common.second && edge1.second)
131128
&& (get(ename_map_common, edge_common.first)
@@ -136,13 +133,10 @@ template < typename Graph > struct test_callback
136133
return (true);
137134
}
138135
}
139-
140-
} // BGL_FORALL_VERTICES_T (subgraph1)
136+
}
141137

142138
// Verify that subgraph2 matches the supplied common subgraph
143-
BGL_FORALL_VERTICES_T(vertex2, subgraph2, MembershipFilteredGraph)
144-
{
145-
139+
for (auto vertex2 : boost::make_iterator_range(vertices(subgraph2))) {
146140
Vertex vertex_common
147141
= vertex(get(vindex_map2, vertex2), m_common_subgraph);
148142

@@ -154,11 +148,9 @@ template < typename Graph > struct test_callback
154148
// Keep looking
155149
return (true);
156150
}
157-
158-
BGL_FORALL_VERTICES_T(vertex2_2, subgraph2, MembershipFilteredGraph)
159-
{
160-
161-
Vertex vertex_common2
151+
152+
for (auto vertex2_2 : boost::make_iterator_range(vertices(subgraph2))) {
153+
Vertex vertex_common2
162154
= vertex(get(vindex_map2, vertex2_2), m_common_subgraph);
163155
EdgeInfo edge_common
164156
= edge(vertex_common, vertex_common2, m_common_subgraph);
@@ -169,13 +161,11 @@ template < typename Graph > struct test_callback
169161
&& (get(ename_map_common, edge_common.first)
170162
!= get(ename_map2, edge2.first))))
171163
{
172-
173164
// Keep looking
174165
return (true);
175166
}
176167
}
177-
178-
} // BGL_FORALL_VERTICES_T (subgraph2)
168+
}
179169

180170
// Check isomorphism just to be thorough
181171
if (verify_isomorphism(subgraph1, subgraph2, correspondence_map_1_to_2))
@@ -223,9 +213,7 @@ template < typename Graph > struct simple_callback
223213

224214
std::stringstream subgraph_string;
225215

226-
BGL_FORALL_VERTICES_T(vertex1, m_graph1, Graph)
227-
{
228-
216+
for (auto vertex1 : boost::make_iterator_range(vertices(m_graph1))) {
229217
Vertex vertex2 = get(correspondence_map_1_to_2, vertex1);
230218

231219
if (vertex2 != boost::graph_traits< Graph >::null_vertex())
@@ -283,15 +271,14 @@ void add_random_vertices(Graph& graph, RandomNumberGenerator& generator,
283271
{
284272
continue;
285273
}
286-
287-
BGL_FORALL_OUTEDGES_T(source_vertex, edge, graph, Graph)
288-
{
274+
275+
for (auto edge : boost::make_iterator_range(out_edges(source_vertex, graph))) {
289276
if (target(edge, graph) == target_vertex)
290277
{
291278
continue;
292279
}
293280
}
294-
281+
295282
put(ename_map, add_edge(source_vertex, target_vertex, graph).first,
296283
generator());
297284

@@ -359,12 +346,8 @@ int main(int argc, char* argv[])
359346
put(vname_map_common, add_vertex(common_subgraph), generator());
360347
}
361348

362-
BGL_FORALL_VERTICES(source_vertex, common_subgraph, Graph)
363-
{
364-
365-
BGL_FORALL_VERTICES(target_vertex, common_subgraph, Graph)
366-
{
367-
349+
for (auto source_vertex : boost::make_iterator_range(vertices(common_subgraph))) {
350+
for (auto target_vertex : boost::make_iterator_range(vertices(common_subgraph))) {
368351
if (source_vertex != target_vertex)
369352
{
370353
put(ename_map_common,
@@ -374,7 +357,7 @@ int main(int argc, char* argv[])
374357
}
375358
}
376359
}
377-
360+
378361
boost::randomize_property< boost::vertex_name_t >(
379362
common_subgraph, generator);
380363
boost::randomize_property< boost::edge_name_t >(common_subgraph, generator);

0 commit comments

Comments
 (0)