Ticket #3151: bgl.diff
File bgl.diff, 18.3 KB (added by , 13 years ago) |
---|
-
adjacency_list_io.hpp
287 287 // assign indices to vertices 288 288 std::map<Vertex,int> indices; 289 289 int num = 0; 290 typename graph_traits<Graph>::vertex_iterator vi ;291 for ( vi = vertices(graph).first; vi != vertices(graph).second; ++vi){290 typename graph_traits<Graph>::vertex_iterator vi, v_end; 291 for (tie(vi, v_end) = vertices(graph); vi != v_end; ++vi){ 292 292 indices[*vi] = num++; 293 293 } 294 294 295 295 // write edges 296 296 PropertyPrinter<Graph, EdgeProperty> print_Edge(graph); 297 297 out << "e" << std::endl; 298 typename graph_traits<Graph>::edge_iterator ei ;299 for ( ei = edges(graph).first; ei != edges(graph).second; ++ei){298 typename graph_traits<Graph>::edge_iterator ei, e_end; 299 for (tie(ei, e_end) = edges(graph); ei != e_end; ++ei){ 300 300 out << indices[source(*ei,graph)] << " " << indices[target(*ei,graph)] << " "; 301 301 print_Edge(out,ei); 302 302 out << std::endl; … … 322 322 { 323 323 PropertyPrinter<Graph, V> printNode(this->graph); 324 324 out << "v"<<std::endl; 325 typename graph_traits<Graph>::vertex_iterator vi ;326 for ( vi = vertices(this->graph).first; vi != vertices(this->graph).second; ++vi){325 typename graph_traits<Graph>::vertex_iterator vi, v_end; 326 for (tie(vi, v_end) = vertices(this->graph); vi != v_end; ++vi){ 327 327 printNode(out,vi); 328 328 out << std::endl; 329 329 } -
pair_util.hpp
1 // 2 //======================================================================= 3 // Copyright 2009 University of Texas at Austin. 4 // Authors: Tim Keitt 5 // 6 // Distributed under the Boost Software License, Version 1.0. (See 7 // accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt) 9 //======================================================================= 10 // 11 #ifndef BOOST_PAIR_UTIL_HPP 12 #define BOOST_PAIR_UTIL_HPP 13 14 #include <utility> 15 16 // 17 // These could not go in graph_utility.hpp 18 // because that file includes depth_first_search.hpp 19 // 20 // Some simple convenience templates for comparing members of a pair 21 // 22 23 namespace boost { 24 25 template<class T> 26 bool 27 is_equal_pair(const std::pair<T, T>& x) 28 { 29 return x.first == x.second; 30 } 31 32 template<class T> 33 bool 34 is_not_equal_pair(const std::pair<T, T>& x) 35 { 36 return x.first != x.second; 37 } 38 39 } /* namespace boost */ 40 41 #endif /* BOOST_PAIR_UTIL_HPP */ -
cuthill_mckee_ordering.hpp
12 12 #define BOOST_GRAPH_CUTHILL_MCKEE_HPP 13 13 14 14 #include <boost/config.hpp> 15 #include <boost/graph/pair_util.hpp> 15 16 #include <boost/graph/detail/sparse_ordering.hpp> 16 17 #include <algorithm> 17 18 … … 132 133 cuthill_mckee_ordering(const Graph& G, OutputIterator permutation, 133 134 ColorMap color, DegreeMap degree) 134 135 { 135 if ( vertices(G).first == vertices(G).second)136 if ( is_equal_pair(vertices(G)) ) 136 137 return permutation; 137 138 138 139 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex; … … 168 169 cuthill_mckee_ordering(const Graph& G, OutputIterator permutation, 169 170 VertexIndexMap index_map) 170 171 { 171 if ( vertices(G).first == vertices(G).second)172 if ( is_equal_pair(vertices(G)) ) 172 173 return permutation; 173 174 174 175 typedef out_degree_property_map<Graph> DegreeMap; -
isomorphism.hpp
439 439 return false; 440 440 #endif 441 441 442 for (typename graph_traits<Graph1>::edge_iterator e1 = edges(g1).first;443 e1 != edges(g1).second; ++e1) {442 typename graph_traits<Graph1>::edge_iterator e1, e1_end; 443 for (tie(e1, e1_end) = edges(g1); e1 != e1_end; ++e1) { 444 444 bool found_edge = false; 445 for (typename graph_traits<Graph2>::edge_iterator e2 = edges(g2).first;446 e2 != edges(g2).second && !found_edge; ++e2) {445 typename graph_traits<Graph2>::edge_iterator e2, e2_end; 446 for (tie(e2, e2_end) = edges(g2); e2 != e2_end && !found_edge; ++e2) { 447 447 if (source(*e2, g2) == get(iso_map, source(*e1, g1)) && 448 448 target(*e2, g2) == get(iso_map, target(*e1, g1))) { 449 449 found_edge = true; -
king_ordering.hpp
12 12 #define BOOST_GRAPH_KING_HPP 13 13 14 14 #include <boost/config.hpp> 15 #include <boost/graph/pair_util.hpp> 15 16 #include <boost/graph/detail/sparse_ordering.hpp> 16 17 17 18 /* … … 262 263 king_ordering(const Graph& G, OutputIterator permutation, 263 264 ColorMap color, DegreeMap degree, VertexIndexMap index_map) 264 265 { 265 if ( vertices(G).first == vertices(G).second)266 if ( is_equal_pair(vertices(G)) ) 266 267 return permutation; 267 268 268 269 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex; … … 298 299 king_ordering(const Graph& G, OutputIterator permutation, 299 300 VertexIndexMap index_map) 300 301 { 301 if ( vertices(G).first == vertices(G).second)302 if ( is_equal_pair(vertices(G)) ) 302 303 return permutation; 303 304 304 305 typedef out_degree_property_map<Graph> DegreeMap; -
bc_clustering.hpp
9 9 #ifndef BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP 10 10 #define BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP 11 11 12 #include <boost/graph/pair_util.hpp> 12 13 #include <boost/graph/betweenness_centrality.hpp> 13 14 #include <boost/graph/graph_traits.hpp> 14 15 #include <boost/pending/indirect_cmp.hpp> … … 116 117 typedef typename graph_traits<MutableGraph>::vertices_size_type 117 118 vertices_size_type; 118 119 119 if ( edges(g).first == edges(g).second) return;120 if (is_equal_pair(edges(g))) return; 120 121 121 122 // Function object that compares the centrality of edges 122 123 indirect_cmp<EdgeCentralityMap, std::less<centrality_type> > … … 127 128 brandes_betweenness_centrality(g, 128 129 edge_centrality_map(edge_centrality) 129 130 .vertex_index_map(vertex_index)); 130 edge_descriptor e = *max_element(edges(g).first, edges(g).second, cmp); 131 edge_iterator ei, e_end; 132 tie(ei, e_end) = edges(g); 133 edge_descriptor e = *max_element(ei, e_end, cmp); 131 134 is_done = done(get(edge_centrality, e), e, g); 132 135 if (!is_done) remove_edge(e, g); 133 } while (!is_done && edges(g).first != edges(g).second);136 } while (!is_done && is_not_equal_pair(edges(g))); 134 137 } 135 138 136 139 /** -
depth_first_search.hpp
14 14 #define BOOST_GRAPH_RECURSIVE_DFS_HPP 15 15 16 16 #include <boost/config.hpp> 17 #include <boost/graph/pair_util.hpp> 17 18 #include <boost/graph/graph_traits.hpp> 18 19 #include <boost/graph/graph_concepts.hpp> 19 20 #include <boost/graph/properties.hpp> … … 214 215 void 215 216 depth_first_search(const VertexListGraph& g, DFSVisitor vis, ColorMap color) 216 217 { 217 if ( vertices(g).first == vertices(g).second)218 if ( is_equal_pair(vertices(g)) ) 218 219 return; 219 220 220 221 depth_first_search(g, vis, color, *vertices(g).first); … … 284 285 depth_first_search(const VertexListGraph& g, 285 286 const bgl_named_params<P, T, R>& params) 286 287 { 287 if ( vertices(g).first == vertices(g).second)288 if ( is_equal_pair(vertices(g)) ) 288 289 return; 289 290 using namespace boost::graph::keywords; 290 291 typedef bgl_named_params<P, T, R> params_type; -
adj_list_serialize.hpp
49 49 // assign indices to vertices 50 50 std::map<Vertex,int> indices; 51 51 int num = 0; 52 typename graph_traits<Graph>::vertex_iterator vi ;53 for ( vi = vertices(graph).first; vi != vertices(graph).second; ++vi) {52 typename graph_traits<Graph>::vertex_iterator vi, v_end; 53 for (tie(vi, v_end) = vertices(graph); vi != v_end; ++vi) { 54 54 indices[*vi] = num++; 55 55 ar << serialization::make_nvp("vertex_property", get(vertex_all_t(), graph, *vi) ); 56 56 } 57 57 58 58 // write edges 59 typename graph_traits<Graph>::edge_iterator ei ;60 for ( ei = edges(graph).first; ei != edges(graph).second; ++ei){59 typename graph_traits<Graph>::edge_iterator ei, e_end; 60 for (tie(ei, e_end) = edges(graph); ei != e_end; ++ei){ 61 61 ar << serialization::make_nvp("u" , indices[source(*ei,graph)]); 62 62 ar << serialization::make_nvp("v" , indices[target(*ei,graph)]); 63 63 ar << serialization::make_nvp("edge_property", get(edge_all_t(), graph, *ei) ); -
push_relabel_max_flow.hpp
19 19 20 20 #include <boost/pending/queue.hpp> 21 21 #include <boost/limits.hpp> 22 #include <boost/graph/pair_util.hpp> 22 23 #include <boost/graph/graph_concepts.hpp> 23 24 #include <boost/graph/named_function_params.hpp> 24 25 … … 121 122 : g(g_), n(num_vertices(g_)), capacity(cap), src(src_), sink(sink_), 122 123 index(idx), 123 124 excess_flow(num_vertices(g_)), 124 current(num_vertices(g_), out_edges(*vertices(g_).first, g_) .second),125 current(num_vertices(g_), out_edges(*vertices(g_).first, g_)), 125 126 distance(num_vertices(g_)), 126 127 color(num_vertices(g_)), 127 128 reverse_edge(rev), … … 149 150 for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { 150 151 vertex_descriptor u = *u_iter; 151 152 excess_flow[u] = 0; 152 current[u] = out_edges(u, g) .first;153 current[u] = out_edges(u, g); 153 154 } 154 155 155 156 bool overflow_detected = false; … … 240 241 && is_residual_edge(reverse_edge[a])) { 241 242 distance[v] = d_v; 242 243 color[v] = ColorTraits::gray(); 243 current[v] = out_edges(v, g) .first;244 current[v] = out_edges(v, g); 244 245 max_distance = max BOOST_PREVENT_MACRO_SUBSTITUTION(d_v, max_distance); 245 246 246 247 if (excess_flow[v] > 0) … … 262 263 assert(excess_flow[u] > 0); 263 264 while (1) { 264 265 out_edge_iterator ai, ai_end; 265 for (ai = current[u], ai_end = out_edges(u, g).second; 266 ai != ai_end; ++ai) { 266 for (tie(ai, ai_end) = current[u]; ai != ai_end; ++ai) { 267 267 edge_descriptor a = *ai; 268 268 if (is_residual_edge(a)) { 269 269 vertex_descriptor v = target(a, g); … … 291 291 if (distance[u] == n) 292 292 break; 293 293 } else { // i is no longer active 294 current[u] = ai;294 current[u].first = ai; 295 295 add_to_inactive_list(u, layer); 296 296 break; 297 297 } … … 350 350 ++min_distance; 351 351 if (min_distance < n) { 352 352 distance[u] = min_distance; // this is the main action 353 current[u] = min_edge_iter;353 current[u].first = min_edge_iter; 354 354 max_distance = max BOOST_PREVENT_MACRO_SUBSTITUTION(min_distance, max_distance); 355 355 } 356 356 return min_distance; … … 444 444 u = *u_iter; 445 445 color[u] = ColorTraits::white(); 446 446 parent[u] = u; 447 current[u] = out_edges(u, g) .first;447 current[u] = out_edges(u, g); 448 448 } 449 449 // eliminate flow cycles and topologically order the vertices 450 450 for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { … … 455 455 r = u; 456 456 color[r] = ColorTraits::gray(); 457 457 while (1) { 458 for (; current[u] != out_edges(u, g).second; ++current[u]) {459 edge_descriptor a = *current[u] ;458 for (; is_not_equal_pair(current[u]); ++current[u].first) { 459 edge_descriptor a = *current[u].first; 460 460 if (capacity[a] == 0 && is_residual_edge(a)) { 461 461 vertex_descriptor v = target(a, g); 462 462 if (color[v] == ColorTraits::white()) { … … 469 469 FlowValue delta = residual_capacity[a]; 470 470 while (1) { 471 471 BOOST_USING_STD_MIN(); 472 delta = min BOOST_PREVENT_MACRO_SUBSTITUTION(delta, residual_capacity[*current[v] ]);472 delta = min BOOST_PREVENT_MACRO_SUBSTITUTION(delta, residual_capacity[*current[v].first]); 473 473 if (v == u) 474 474 break; 475 475 else 476 v = target(*current[v] , g);476 v = target(*current[v].first, g); 477 477 } 478 478 // remove delta flow units 479 479 v = u; 480 480 while (1) { 481 a = *current[v] ;481 a = *current[v].first; 482 482 residual_capacity[a] -= delta; 483 483 residual_capacity[reverse_edge[a]] += delta; 484 484 v = target(a, g); … … 488 488 489 489 // back-out of DFS to the first saturated edge 490 490 restart = u; 491 for (v = target(*current[u] , g); v != u; v = target(a, g)){492 a = *current[v] ;491 for (v = target(*current[u].first, g); v != u; v = target(a, g)){ 492 a = *current[v].first; 493 493 if (color[v] == ColorTraits::white() 494 494 || is_saturated(a)) { 495 color[target(*current[v] , g)] = ColorTraits::white();495 color[target(*current[v].first, g)] = ColorTraits::white(); 496 496 if (color[v] != ColorTraits::white()) 497 497 restart = v; 498 498 } 499 499 } 500 500 if (restart != u) { 501 501 u = restart; 502 ++current[u] ;502 ++current[u].first; 503 503 break; 504 504 } 505 505 } // else if (color[v] == ColorTraits::gray()) 506 506 } // if (capacity[a] == 0 ... 507 507 } // for out_edges(u, g) (though "u" changes during loop) 508 508 509 if ( current[u] == out_edges(u, g).second) {509 if ( is_equal_pair(current[u]) ) { 510 510 // scan of i is complete 511 511 color[u] = ColorTraits::black(); 512 512 if (u != src) { … … 521 521 } 522 522 if (u != r) { 523 523 u = parent[u]; 524 ++current[u] ;524 ++current[u].first; 525 525 } else 526 526 break; 527 527 } … … 533 533 // note that the sink is not on the stack 534 534 if (! bos_null) { 535 535 for (u = tos; u != bos; u = topo_next[u]) { 536 ai = out_edges(u, g).first;537 while (excess_flow[u] > 0 && ai != out_edges(u, g).second) {536 tie(ai, a_end) = out_edges(u, g); 537 while (excess_flow[u] > 0 && ai != a_end) { 538 538 if (capacity[*ai] == 0 && is_residual_edge(*ai)) 539 539 push_flow(*ai); 540 540 ++ai; … … 632 632 633 633 // will need to use random_access_property_map with these 634 634 std::vector< FlowValue > excess_flow; 635 std::vector< out_edge_iterator> current;635 std::vector< std::pair<out_edge_iterator, out_edge_iterator> > current; 636 636 std::vector< distance_size_type > distance; 637 637 std::vector< default_color_type > color; 638 638 -
howard_cycle_ratio.hpp
25 25 #include <boost/type_traits/remove_const.hpp> 26 26 #include <boost/type_traits/is_signed.hpp> 27 27 #include <boost/concept_check.hpp> 28 #include <boost/graph/pair_util.hpp> 28 29 #include <boost/graph/adjacency_list.hpp> 29 30 #include <boost/graph/reverse_graph.hpp> 30 31 #include <boost/graph/breadth_first_search.hpp> … … 172 173 } 173 174 BGL_FORALL_VERTICES_T(vd1, m_g, TGraph) 174 175 { 175 if ( boost::out_edges(vd1, m_g).first == boost::out_edges(vd1, m_g).second) throw bad_graph(m_vim[vd1]);176 if ( is_equal_pair(boost::out_edges(vd1, m_g)) ) throw bad_graph(m_vim[vd1]); 176 177 mcr_edge_t ed = *boost::out_edges(vd1, m_g).first; 177 178 pi_edge_t pied = boost::add_edge(m_g2pi_g_vm[source(ed, m_g)], m_g2pi_g_vm[target(ed, m_g)], m_pi_g).first; 178 179 boost::put(boost::edge_weight, m_pi_g, pied, m_ew1m[ed]); -
edge_connectivity.hpp
132 132 detail::neighbors(g, S.begin(), S.end(), 133 133 std::inserter(neighbor_S, neighbor_S.begin())); 134 134 135 std::set_difference(vertices(g).first, vertices(g).second, 135 tie(vi, vi_end) = vertices(g); 136 std::set_difference(vi, vi_end, 136 137 neighbor_S.begin(), neighbor_S.end(), 137 138 std::back_inserter(non_neighbor_S)); 138 139 … … 153 154 neighbor_S.insert(k); 154 155 detail::neighbors(g, k, std::inserter(neighbor_S, neighbor_S.begin())); 155 156 non_neighbor_S.clear(); 156 std::set_difference(vertices(g).first, vertices(g).second, 157 tie(vi, vi_end) = vertices(g); 158 std::set_difference(vi, vi_end, 157 159 neighbor_S.begin(), neighbor_S.end(), 158 160 std::back_inserter(non_neighbor_S)); 159 161 }