Index: adjacency_list_io.hpp =================================================================== --- adjacency_list_io.hpp (revision 53754) +++ adjacency_list_io.hpp (working copy) @@ -287,16 +287,16 @@ // assign indices to vertices std::map indices; int num = 0; - typename graph_traits::vertex_iterator vi; - for (vi = vertices(graph).first; vi != vertices(graph).second; ++vi){ + typename graph_traits::vertex_iterator vi, v_end; + for (tie(vi, v_end) = vertices(graph); vi != v_end; ++vi){ indices[*vi] = num++; } // write edges PropertyPrinter print_Edge(graph); out << "e" << std::endl; - typename graph_traits::edge_iterator ei; - for (ei = edges(graph).first; ei != edges(graph).second; ++ei){ + typename graph_traits::edge_iterator ei, e_end; + for (tie(ei, e_end) = edges(graph); ei != e_end; ++ei){ out << indices[source(*ei,graph)] << " " << indices[target(*ei,graph)] << " "; print_Edge(out,ei); out << std::endl; @@ -322,8 +322,8 @@ { PropertyPrinter printNode(this->graph); out << "v"<::vertex_iterator vi; - for (vi = vertices(this->graph).first; vi != vertices(this->graph).second; ++vi){ + typename graph_traits::vertex_iterator vi, v_end; + for (tie(vi, v_end) = vertices(this->graph); vi != v_end; ++vi){ printNode(out,vi); out << std::endl; } Index: pair_util.hpp =================================================================== --- pair_util.hpp (revision 0) +++ pair_util.hpp (revision 0) @@ -0,0 +1,41 @@ +// +//======================================================================= +// Copyright 2009 University of Texas at Austin. +// Authors: Tim Keitt +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= +// +#ifndef BOOST_PAIR_UTIL_HPP +#define BOOST_PAIR_UTIL_HPP + +#include + +// +// These could not go in graph_utility.hpp +// because that file includes depth_first_search.hpp +// +// Some simple convenience templates for comparing members of a pair +// + +namespace boost { + +template +bool +is_equal_pair(const std::pair& x) +{ + return x.first == x.second; +} + +template +bool +is_not_equal_pair(const std::pair& x) +{ + return x.first != x.second; +} + +} /* namespace boost */ + +#endif /* BOOST_PAIR_UTIL_HPP */ Index: cuthill_mckee_ordering.hpp =================================================================== --- cuthill_mckee_ordering.hpp (revision 53754) +++ cuthill_mckee_ordering.hpp (working copy) @@ -12,6 +12,7 @@ #define BOOST_GRAPH_CUTHILL_MCKEE_HPP #include +#include #include #include @@ -132,7 +133,7 @@ cuthill_mckee_ordering(const Graph& G, OutputIterator permutation, ColorMap color, DegreeMap degree) { - if (vertices(G).first == vertices(G).second) + if ( is_equal_pair(vertices(G)) ) return permutation; typedef typename boost::graph_traits::vertex_descriptor Vertex; @@ -168,7 +169,7 @@ cuthill_mckee_ordering(const Graph& G, OutputIterator permutation, VertexIndexMap index_map) { - if (vertices(G).first == vertices(G).second) + if ( is_equal_pair(vertices(G)) ) return permutation; typedef out_degree_property_map DegreeMap; Index: isomorphism.hpp =================================================================== --- isomorphism.hpp (revision 53754) +++ isomorphism.hpp (working copy) @@ -439,11 +439,11 @@ return false; #endif - for (typename graph_traits::edge_iterator e1 = edges(g1).first; - e1 != edges(g1).second; ++e1) { + typename graph_traits::edge_iterator e1, e1_end; + for (tie(e1, e1_end) = edges(g1); e1 != e1_end; ++e1) { bool found_edge = false; - for (typename graph_traits::edge_iterator e2 = edges(g2).first; - e2 != edges(g2).second && !found_edge; ++e2) { + typename graph_traits::edge_iterator e2, e2_end; + for (tie(e2, e2_end) = edges(g2); e2 != e2_end && !found_edge; ++e2) { if (source(*e2, g2) == get(iso_map, source(*e1, g1)) && target(*e2, g2) == get(iso_map, target(*e1, g1))) { found_edge = true; Index: king_ordering.hpp =================================================================== --- king_ordering.hpp (revision 53754) +++ king_ordering.hpp (working copy) @@ -12,6 +12,7 @@ #define BOOST_GRAPH_KING_HPP #include +#include #include /* @@ -262,7 +263,7 @@ king_ordering(const Graph& G, OutputIterator permutation, ColorMap color, DegreeMap degree, VertexIndexMap index_map) { - if (vertices(G).first == vertices(G).second) + if ( is_equal_pair(vertices(G)) ) return permutation; typedef typename boost::graph_traits::vertex_descriptor Vertex; @@ -298,7 +299,7 @@ king_ordering(const Graph& G, OutputIterator permutation, VertexIndexMap index_map) { - if (vertices(G).first == vertices(G).second) + if ( is_equal_pair(vertices(G)) ) return permutation; typedef out_degree_property_map DegreeMap; Index: bc_clustering.hpp =================================================================== --- bc_clustering.hpp (revision 53754) +++ bc_clustering.hpp (working copy) @@ -9,6 +9,7 @@ #ifndef BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP #define BOOST_GRAPH_BETWEENNESS_CENTRALITY_CLUSTERING_HPP +#include #include #include #include @@ -116,7 +117,7 @@ typedef typename graph_traits::vertices_size_type vertices_size_type; - if (edges(g).first == edges(g).second) return; + if (is_equal_pair(edges(g))) return; // Function object that compares the centrality of edges indirect_cmp > @@ -127,10 +128,12 @@ brandes_betweenness_centrality(g, edge_centrality_map(edge_centrality) .vertex_index_map(vertex_index)); - edge_descriptor e = *max_element(edges(g).first, edges(g).second, cmp); + edge_iterator ei, e_end; + tie(ei, e_end) = edges(g); + edge_descriptor e = *max_element(ei, e_end, cmp); is_done = done(get(edge_centrality, e), e, g); if (!is_done) remove_edge(e, g); - } while (!is_done && edges(g).first != edges(g).second); + } while (!is_done && is_not_equal_pair(edges(g))); } /** Index: depth_first_search.hpp =================================================================== --- depth_first_search.hpp (revision 53754) +++ depth_first_search.hpp (working copy) @@ -14,6 +14,7 @@ #define BOOST_GRAPH_RECURSIVE_DFS_HPP #include +#include #include #include #include @@ -214,7 +215,7 @@ void depth_first_search(const VertexListGraph& g, DFSVisitor vis, ColorMap color) { - if (vertices(g).first == vertices(g).second) + if ( is_equal_pair(vertices(g)) ) return; depth_first_search(g, vis, color, *vertices(g).first); @@ -284,7 +285,7 @@ depth_first_search(const VertexListGraph& g, const bgl_named_params& params) { - if (vertices(g).first == vertices(g).second) + if ( is_equal_pair(vertices(g)) ) return; using namespace boost::graph::keywords; typedef bgl_named_params params_type; Index: adj_list_serialize.hpp =================================================================== --- adj_list_serialize.hpp (revision 53754) +++ adj_list_serialize.hpp (working copy) @@ -49,15 +49,15 @@ // assign indices to vertices std::map indices; int num = 0; - typename graph_traits::vertex_iterator vi; - for (vi = vertices(graph).first; vi != vertices(graph).second; ++vi) { + typename graph_traits::vertex_iterator vi, v_end; + for (tie(vi, v_end) = vertices(graph); vi != v_end; ++vi) { indices[*vi] = num++; ar << serialization::make_nvp("vertex_property", get(vertex_all_t(), graph, *vi) ); } // write edges - typename graph_traits::edge_iterator ei; - for (ei = edges(graph).first; ei != edges(graph).second; ++ei){ + typename graph_traits::edge_iterator ei, e_end; + for (tie(ei, e_end) = edges(graph); ei != e_end; ++ei){ ar << serialization::make_nvp("u" , indices[source(*ei,graph)]); ar << serialization::make_nvp("v" , indices[target(*ei,graph)]); ar << serialization::make_nvp("edge_property", get(edge_all_t(), graph, *ei) ); Index: push_relabel_max_flow.hpp =================================================================== --- push_relabel_max_flow.hpp (revision 53754) +++ push_relabel_max_flow.hpp (working copy) @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -121,7 +122,7 @@ : g(g_), n(num_vertices(g_)), capacity(cap), src(src_), sink(sink_), index(idx), excess_flow(num_vertices(g_)), - current(num_vertices(g_), out_edges(*vertices(g_).first, g_).second), + current(num_vertices(g_), out_edges(*vertices(g_).first, g_)), distance(num_vertices(g_)), color(num_vertices(g_)), reverse_edge(rev), @@ -149,7 +150,7 @@ for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { vertex_descriptor u = *u_iter; excess_flow[u] = 0; - current[u] = out_edges(u, g).first; + current[u] = out_edges(u, g); } bool overflow_detected = false; @@ -240,7 +241,7 @@ && is_residual_edge(reverse_edge[a])) { distance[v] = d_v; color[v] = ColorTraits::gray(); - current[v] = out_edges(v, g).first; + current[v] = out_edges(v, g); max_distance = max BOOST_PREVENT_MACRO_SUBSTITUTION(d_v, max_distance); if (excess_flow[v] > 0) @@ -262,8 +263,7 @@ assert(excess_flow[u] > 0); while (1) { out_edge_iterator ai, ai_end; - for (ai = current[u], ai_end = out_edges(u, g).second; - ai != ai_end; ++ai) { + for (tie(ai, ai_end) = current[u]; ai != ai_end; ++ai) { edge_descriptor a = *ai; if (is_residual_edge(a)) { vertex_descriptor v = target(a, g); @@ -291,7 +291,7 @@ if (distance[u] == n) break; } else { // i is no longer active - current[u] = ai; + current[u].first = ai; add_to_inactive_list(u, layer); break; } @@ -350,7 +350,7 @@ ++min_distance; if (min_distance < n) { distance[u] = min_distance; // this is the main action - current[u] = min_edge_iter; + current[u].first = min_edge_iter; max_distance = max BOOST_PREVENT_MACRO_SUBSTITUTION(min_distance, max_distance); } return min_distance; @@ -444,7 +444,7 @@ u = *u_iter; color[u] = ColorTraits::white(); parent[u] = u; - current[u] = out_edges(u, g).first; + current[u] = out_edges(u, g); } // eliminate flow cycles and topologically order the vertices for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { @@ -455,8 +455,8 @@ r = u; color[r] = ColorTraits::gray(); while (1) { - for (; current[u] != out_edges(u, g).second; ++current[u]) { - edge_descriptor a = *current[u]; + for (; is_not_equal_pair(current[u]); ++current[u].first) { + edge_descriptor a = *current[u].first; if (capacity[a] == 0 && is_residual_edge(a)) { vertex_descriptor v = target(a, g); if (color[v] == ColorTraits::white()) { @@ -469,16 +469,16 @@ FlowValue delta = residual_capacity[a]; while (1) { BOOST_USING_STD_MIN(); - delta = min BOOST_PREVENT_MACRO_SUBSTITUTION(delta, residual_capacity[*current[v]]); + delta = min BOOST_PREVENT_MACRO_SUBSTITUTION(delta, residual_capacity[*current[v].first]); if (v == u) break; else - v = target(*current[v], g); + v = target(*current[v].first, g); } // remove delta flow units v = u; while (1) { - a = *current[v]; + a = *current[v].first; residual_capacity[a] -= delta; residual_capacity[reverse_edge[a]] += delta; v = target(a, g); @@ -488,25 +488,25 @@ // back-out of DFS to the first saturated edge restart = u; - for (v = target(*current[u], g); v != u; v = target(a, g)){ - a = *current[v]; + for (v = target(*current[u].first, g); v != u; v = target(a, g)){ + a = *current[v].first; if (color[v] == ColorTraits::white() || is_saturated(a)) { - color[target(*current[v], g)] = ColorTraits::white(); + color[target(*current[v].first, g)] = ColorTraits::white(); if (color[v] != ColorTraits::white()) restart = v; } } if (restart != u) { u = restart; - ++current[u]; + ++current[u].first; break; } } // else if (color[v] == ColorTraits::gray()) } // if (capacity[a] == 0 ... } // for out_edges(u, g) (though "u" changes during loop) - if (current[u] == out_edges(u, g).second) { + if ( is_equal_pair(current[u]) ) { // scan of i is complete color[u] = ColorTraits::black(); if (u != src) { @@ -521,7 +521,7 @@ } if (u != r) { u = parent[u]; - ++current[u]; + ++current[u].first; } else break; } @@ -533,8 +533,8 @@ // note that the sink is not on the stack if (! bos_null) { for (u = tos; u != bos; u = topo_next[u]) { - ai = out_edges(u, g).first; - while (excess_flow[u] > 0 && ai != out_edges(u, g).second) { + tie(ai, a_end) = out_edges(u, g); + while (excess_flow[u] > 0 && ai != a_end) { if (capacity[*ai] == 0 && is_residual_edge(*ai)) push_flow(*ai); ++ai; @@ -632,7 +632,7 @@ // will need to use random_access_property_map with these std::vector< FlowValue > excess_flow; - std::vector< out_edge_iterator > current; + std::vector< std::pair > current; std::vector< distance_size_type > distance; std::vector< default_color_type > color; Index: howard_cycle_ratio.hpp =================================================================== --- howard_cycle_ratio.hpp (revision 53754) +++ howard_cycle_ratio.hpp (working copy) @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -172,7 +173,7 @@ } BGL_FORALL_VERTICES_T(vd1, m_g, TGraph) { - if (boost::out_edges(vd1, m_g).first == boost::out_edges(vd1, m_g).second) throw bad_graph(m_vim[vd1]); + if ( is_equal_pair(boost::out_edges(vd1, m_g)) ) throw bad_graph(m_vim[vd1]); mcr_edge_t ed = *boost::out_edges(vd1, m_g).first; 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; boost::put(boost::edge_weight, m_pi_g, pied, m_ew1m[ed]); Index: edge_connectivity.hpp =================================================================== --- edge_connectivity.hpp (revision 53754) +++ edge_connectivity.hpp (working copy) @@ -132,7 +132,8 @@ detail::neighbors(g, S.begin(), S.end(), std::inserter(neighbor_S, neighbor_S.begin())); - std::set_difference(vertices(g).first, vertices(g).second, + tie(vi, vi_end) = vertices(g); + std::set_difference(vi, vi_end, neighbor_S.begin(), neighbor_S.end(), std::back_inserter(non_neighbor_S)); @@ -153,7 +154,8 @@ neighbor_S.insert(k); detail::neighbors(g, k, std::inserter(neighbor_S, neighbor_S.begin())); non_neighbor_S.clear(); - std::set_difference(vertices(g).first, vertices(g).second, + tie(vi, vi_end) = vertices(g); + std::set_difference(vi, vi_end, neighbor_S.begin(), neighbor_S.end(), std::back_inserter(non_neighbor_S)); }