Skip to content

Commit 9a762a8

Browse files
authored
Merge pull request #618 from NNhanptnk/BGL_FORALL_-mcgregor_common_subgraphs_hpp
Refactor : replace BGL_FORALL_* macro with range-based in mcgregor_common_subgraphs.hpp
2 parents ed9c759 + ef5d845 commit 9a762a8

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

‎include/boost/graph/mcgregor_common_subgraphs.hpp‎

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include <stack>
1616

1717
#include <memory>
18-
#include <boost/graph/adjacency_list.hpp>
18+
#include <boost/graph/adjacency_list.hpp>
19+
#include <boost/range/iterator_range.hpp>
1920
#include <boost/graph/filtered_graph.hpp>
2021
#include <boost/graph/graph_utility.hpp>
21-
#include <boost/graph/iteration_macros.hpp>
2222
#include <boost/graph/properties.hpp>
2323
#include <boost/property_map/shared_array_property_map.hpp>
2424

@@ -144,8 +144,7 @@ namespace detail
144144

145145
bool has_one_edge = false;
146146

147-
// Verify edges with existing sub-graph
148-
BGL_FORALL_VERTICES_T(existing_vertex1, graph1, GraphFirst)
147+
for (const auto& existing_vertex1 : boost::make_iterator_range(vertices(graph1)))
149148
{
150149

151150
VertexSecond existing_vertex2
@@ -166,7 +165,7 @@ namespace detail
166165
bool edge_to_new_exists2 = false, edge_from_new_exists2 = false;
167166

168167
// Search for edge from existing to new vertex (graph1)
169-
BGL_FORALL_OUTEDGES_T(existing_vertex1, edge1, graph1, GraphFirst)
168+
for (const auto & edge1 : boost::make_iterator_range(out_edges(existing_vertex1, graph1)))
170169
{
171170
if (target(edge1, graph1) == new_vertex1)
172171
{
@@ -177,7 +176,7 @@ namespace detail
177176
}
178177

179178
// Search for edge from existing to new vertex (graph2)
180-
BGL_FORALL_OUTEDGES_T(existing_vertex2, edge2, graph2, GraphSecond)
179+
for (const auto & edge2 : boost::make_iterator_range(out_edges(existing_vertex2, graph2)))
181180
{
182181
if (target(edge2, graph2) == new_vertex2)
183182
{
@@ -217,8 +216,7 @@ namespace detail
217216
{
218217

219218
// Search for edge from new to existing vertex (graph1)
220-
BGL_FORALL_OUTEDGES_T(
221-
new_vertex1, edge1, graph1, GraphFirst)
219+
for (const auto& edge1 : boost::make_iterator_range(out_edges(new_vertex1, graph1)))
222220
{
223221
if (target(edge1, graph1) == existing_vertex1)
224222
{
@@ -233,8 +231,7 @@ namespace detail
233231
{
234232

235233
// Search for edge from new to existing vertex (graph2)
236-
BGL_FORALL_OUTEDGES_T(
237-
new_vertex2, edge2, graph2, GraphSecond)
234+
for (const auto& edge2 : boost::make_iterator_range(out_edges(new_vertex2, graph2)))
238235
{
239236
if (target(edge2, graph2) == existing_vertex2)
240237
{
@@ -262,7 +259,8 @@ namespace detail
262259

263260
} // else
264261

265-
} // BGL_FORALL_VERTICES_T
262+
}
263+
266264

267265
// Make sure new vertices are connected to the existing subgraph
268266
if (only_connected_subgraphs && !has_one_edge)
@@ -317,7 +315,8 @@ namespace detail
317315
vertex2_iter = vertex2_begin;
318316

319317
// Iterate until all vertices have been visited
320-
BGL_FORALL_VERTICES_T(new_vertex1, graph1, GraphFirst)
318+
319+
for (const auto& new_vertex1 : boost::make_iterator_range(vertices(graph1)))
321320
{
322321

323322
VertexSecond existing_vertex2
@@ -329,7 +328,7 @@ namespace detail
329328
continue;
330329
}
331330

332-
BGL_FORALL_VERTICES_T(new_vertex2, graph2, GraphSecond)
331+
for (const auto& new_vertex2 : boost::make_iterator_range(vertices(graph2)))
333332
{
334333

335334
VertexFirst existing_vertex1
@@ -402,10 +401,10 @@ namespace detail
402401

403402
} // if can_extend_graph
404403

405-
} // BGL_FORALL_VERTICES_T (graph2)
406-
407-
} // BGL_FORALL_VERTICES_T (graph1)
404+
}
408405

406+
}
407+
409408
return (true);
410409
}
411410

@@ -431,7 +430,7 @@ namespace detail
431430
typename SubGraphTraits::correspondence_map_first_to_second_type
432431
correspondence_map_1_to_2(num_vertices(graph1), vindex_map1);
433432

434-
BGL_FORALL_VERTICES_T(vertex1, graph1, GraphFirst)
433+
for (const auto& vertex1 : boost::make_iterator_range(vertices(graph1)))
435434
{
436435
put(correspondence_map_1_to_2, vertex1,
437436
graph_traits< GraphSecond >::null_vertex());
@@ -440,7 +439,7 @@ namespace detail
440439
typename SubGraphTraits::correspondence_map_second_to_first_type
441440
correspondence_map_2_to_1(num_vertices(graph2), vindex_map2);
442441

443-
BGL_FORALL_VERTICES_T(vertex2, graph2, GraphSecond)
442+
for (const auto& vertex2 : boost::make_iterator_range(vertices(graph2)))
444443
{
445444
put(correspondence_map_2_to_1, vertex2,
446445
graph_traits< GraphFirst >::null_vertex());
@@ -602,14 +601,14 @@ namespace detail
602601
CachedCorrespondenceMapSecondToFirst new_subgraph_2_to_1
603602
= CorrespondenceMapSecondToFirst(
604603
num_vertices(m_graph2), m_vindex_map2);
605-
606-
BGL_FORALL_VERTICES_T(vertex1, m_graph1, GraphFirst)
604+
605+
for (const auto& vertex1 : boost::make_iterator_range(vertices(m_graph1)))
607606
{
608607
put(new_subgraph_1_to_2, vertex1,
609608
get(correspondence_map_1_to_2, vertex1));
610609
}
611610

612-
BGL_FORALL_VERTICES_T(vertex2, m_graph2, GraphFirst)
611+
for (const auto& vertex2 : boost::make_iterator_range(vertices(m_graph2)))
613612
{
614613
put(new_subgraph_2_to_1, vertex2,
615614
get(correspondence_map_2_to_1, vertex2));
@@ -764,13 +763,13 @@ namespace detail
764763
= CachedCorrespondenceMapSecondToFirst(
765764
num_vertices(m_graph2), m_vindex_map2);
766765

767-
BGL_FORALL_VERTICES_T(vertex1, m_graph1, GraphFirst)
766+
for (const auto& vertex1 : boost::make_iterator_range(vertices(m_graph1)))
768767
{
769768
put(new_subgraph_1_to_2, vertex1,
770769
get(correspondence_map_1_to_2, vertex1));
771770
}
772771

773-
BGL_FORALL_VERTICES_T(vertex2, m_graph2, GraphFirst)
772+
for (const auto& vertex2 : boost::make_iterator_range(vertices(m_graph2)))
774773
{
775774
put(new_subgraph_2_to_1, vertex2,
776775
get(correspondence_map_2_to_1, vertex2));
@@ -958,14 +957,14 @@ namespace detail
958957
CachedCorrespondenceMapSecondToFirst new_subgraph_2_to_1
959958
= CachedCorrespondenceMapSecondToFirst(
960959
num_vertices(m_graph2), m_vindex_map2);
961-
962-
BGL_FORALL_VERTICES_T(vertex1, m_graph1, GraphFirst)
960+
961+
for (const auto& vertex1 : boost::make_iterator_range(vertices(m_graph1)))
963962
{
964963
put(new_subgraph_1_to_2, vertex1,
965964
get(correspondence_map_1_to_2, vertex1));
966965
}
967966

968-
BGL_FORALL_VERTICES_T(vertex2, m_graph2, GraphFirst)
967+
for (const auto& vertex2 : boost::make_iterator_range(vertices(m_graph2)))
969968
{
970969
put(new_subgraph_2_to_1, vertex2,
971970
get(correspondence_map_2_to_1, vertex2));
@@ -1079,7 +1078,7 @@ void fill_membership_map(const GraphFirst& graph1,
10791078
MembershipMapFirst membership_map1)
10801079
{
10811080

1082-
BGL_FORALL_VERTICES_T(vertex1, graph1, GraphFirst)
1081+
for (const auto& vertex1 : boost::make_iterator_range(vertices(graph1)))
10831082
{
10841083
put(membership_map1, vertex1,
10851084
get(correspondence_map_1_to_2, vertex1)

0 commit comments

Comments
 (0)