From 73e78c7313f74b096bda34227fbf41507dca5006 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 May 2016 13:36:02 +0200 Subject: [PATCH 01/28] Avoid unused variable warning. --- example/graph-thingie.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index 6b8031dd..748d385d 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace boost; using namespace std; @@ -102,5 +103,5 @@ const char* dot = " (" << get("label",dp,v) << ")\n"; } - return 0; + return status ? EXIT_SUCCESS : EXIT_FAILURE; } From 538a9156eeaf0e7f4ba227300173a0a80583743a Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 May 2016 13:38:27 +0200 Subject: [PATCH 02/28] Avoid signed/unsigned comparison warning. --- example/fibonacci_heap.cpp | 2 +- example/prim-telephone.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index 3dbdc5c9..2f1f1e95 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -27,7 +27,7 @@ main() for (int N = 2; N < 200; ++N) { uniform_int<> distrib(0, N-1); variate_generator > rand_gen(gen, distrib); - for (int t = 0; t < 10; ++t) { + for (std::size_t t = 0; t < 10; ++t) { std::vector v, w(N); ICmp cmp(&w[0], std::less()); diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 6b6f914f..319940d3 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -44,12 +44,12 @@ main() #endif int total_weight = 0; - for (int v = 0; v < num_vertices(g); ++v) + for (std::size_t v = 0; v < num_vertices(g); ++v) if (parent[v] != v) total_weight += get(weight, edge(parent[v], v, g).first); std::cout << "total weight: " << total_weight << std::endl; - for (int u = 0; u < num_vertices(g); ++u) + for (std::size_t u = 0; u < num_vertices(g); ++u) if (parent[u] != u) edge_attr_map[edge(parent[u], u, g_dot).first]["color"] = "black"; std::ofstream out("figs/telephone-mst-prim.dot"); From bfaddb5867a1f3e8596335af10c6a4dd92e87cab Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 3 May 2016 14:11:57 +0200 Subject: [PATCH 03/28] examples: C++11: Use auto. --- example/accum-compile-times.cpp | 10 ++++----- example/actor_clustering.cpp | 18 +++++++--------- example/adjacency_list.cpp | 6 ++---- example/astar-cities.cpp | 14 ++++++------ example/astar_maze.cpp | 16 +++++++------- example/bellman-example.cpp | 11 ++++------ example/bfs-example2.cpp | 2 +- example/bfs-name-printer.cpp | 17 +++++++-------- example/bfs.cpp | 2 +- example/bfs_neighbor.cpp | 2 +- example/biconnected_components.cpp | 5 ++--- example/boost_web_graph.cpp | 14 ++++++------ example/boykov_kolmogorov-eg.cpp | 10 ++++----- example/bron_kerbosch_clique_number.cpp | 2 +- example/bucket_sorter.cpp | 8 +++---- example/canonical_ordering.cpp | 7 +++--- example/cc-internet.cpp | 3 +-- example/city_visitor.cpp | 3 +-- example/clustering_coefficient.cpp | 2 +- example/connected-components.cpp | 2 +- example/connected_components.cpp | 2 +- example/copy-example.cpp | 3 +-- example/cuthill_mckee_ordering.cpp | 15 ++++++------- example/cycle_canceling_example.cpp | 2 +- example/cycle_ratio_example.cpp | 16 +++++++------- example/dag_shortest_paths.cpp | 5 ++--- example/dave.cpp | 3 +-- example/dijkstra-example-listS.cpp | 19 +++++++--------- example/dijkstra-example.cpp | 9 ++++---- example/dijkstra-no-color-map-example.cpp | 7 +++--- example/directed_graph.cpp | 4 ++-- example/edge-connectivity.cpp | 25 ++++++++-------------- example/edge-function.cpp | 6 +++--- example/edge_basics.cpp | 4 ++-- example/edge_connectivity.cpp | 2 +- example/edge_iterator_constructor.cpp | 2 +- example/edge_property.cpp | 6 ++---- example/edmonds-karp-eg.cpp | 8 +++---- example/family_tree.cpp | 7 +++--- example/filtered-copy-example.cpp | 3 +-- example/filtered_graph_edge_range.cpp | 7 +++--- example/gerdemann.cpp | 8 +++---- example/girth.cpp | 4 ++-- example/graph-thingie.cpp | 12 ++++------- example/graph_as_tree.cpp | 5 ++--- example/grid_graph_properties.cpp | 2 +- example/hawick_circuits.cpp | 6 +----- example/implicit_graph.cpp | 2 +- example/influence_prestige.cpp | 2 +- example/interior_property_map.cpp | 2 +- example/iteration_macros.cpp | 3 +-- example/johnson-eg.cpp | 2 +- example/kevin-bacon.cpp | 6 ++---- example/kevin-bacon2.cpp | 2 +- example/king_ordering.cpp | 13 ++++++----- example/kruskal-example.cpp | 6 +++--- example/kruskal-telephone.cpp | 10 ++++----- example/kuratowski_subgraph.cpp | 2 +- example/last-mod-time.cpp | 5 ++--- example/leda-graph-eg.cpp | 2 +- example/loops_dfs.cpp | 16 +++++++------- example/make_biconnected_planar.cpp | 2 +- example/make_maximal_planar.cpp | 2 +- example/matching_example.cpp | 4 ++-- example/max_flow.cpp | 9 +++----- example/mcgregor_subgraphs_example.cpp | 6 ++---- example/mean_geodesic.cpp | 2 +- example/miles_span.cpp | 6 ++---- example/min_max_paths.cpp | 4 ++-- example/minimum_degree_ordering.cpp | 3 +-- example/modify_graph.cpp | 3 +-- example/neighbor_bfs.cpp | 6 ++---- example/ordered_out_edges.cpp | 4 ++-- example/ospf-example.cpp | 6 +++--- example/planar_face_traversal.cpp | 2 +- example/prim-example.cpp | 6 +++--- example/prim-telephone.cpp | 9 ++++---- example/property-map-traits-eg.cpp | 3 +-- example/property_iterator.cpp | 6 ++---- example/push-relabel-eg.cpp | 10 ++++----- example/quick-tour.cpp | 8 +++---- example/quick_tour.cpp | 7 +++--- example/reachable-loop-head.cpp | 7 +++--- example/reachable-loop-tail.cpp | 5 ++--- example/read_graphviz.cpp | 9 +++----- example/read_write_dimacs-eg.cpp | 12 +++++------ example/remove_edge_if_bidir.cpp | 4 ++-- example/remove_edge_if_undir.cpp | 2 +- example/roget_components.cpp | 10 ++++----- example/scc.cpp | 3 +-- example/sloan_ordering.cpp | 8 +++---- example/strong-components.cpp | 3 +-- example/subgraph_properties.cpp | 6 +++--- ...e_shortest_path_nonnegative_weights_example.cpp | 2 +- example/tiernan_print_cycles.cpp | 3 +-- example/topo-sort-with-leda.cpp | 2 +- example/topo-sort-with-sgb.cpp | 2 +- example/topo-sort1.cpp | 2 +- example/topo-sort2.cpp | 2 +- example/topo_sort.cpp | 4 ++-- example/transpose-example.cpp | 3 +-- example/two_graphs_common_spanning_trees.cpp | 5 ++--- example/undirected_adjacency_list.cpp | 23 ++++++++------------ example/undirected_graph.cpp | 6 +++--- example/vertex-name-property.cpp | 3 +-- example/vertex_basics.cpp | 7 +++--- example/vf2_sub_graph_iso_multi_example.cpp | 9 ++------ include/boost/graph/bc_clustering.hpp | 6 ++---- 108 files changed, 286 insertions(+), 389 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 85af0482..02651c15 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -69,12 +69,10 @@ main() file_dep_graph2 g(input_begin, input_end, n_vertices); #endif - typedef property_map < file_dep_graph2, vertex_name_t >::type name_map_t; - typedef property_map < file_dep_graph2, vertex_compile_cost_t >::type - compile_cost_map_t; - - name_map_t name_map = get(vertex_name, g); - compile_cost_map_t compile_cost_map = get(vertex_compile_cost, g); + auto name_map = get(vertex_name, g); + auto compile_cost_map = get(vertex_compile_cost, g); + auto distance_map = get(vertex_distance, g); + auto color_map = get(vertex_color, g); std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 9b1b4022..45623ca1 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -50,11 +50,11 @@ void load_actor_graph(std::istream& in, ActorGraph& g) // Map from the actor numbers on this line to the actor vertices typedef tokenizer > Tok; Tok tok(line, char_separator(" ")); - for (Tok::iterator id = tok.begin(); id != tok.end(); ++id) { - int actor_id = lexical_cast(*id); - std::map::iterator v = actors.find(actor_id); + for (const auto& id : tok) { + auto actor_id = lexical_cast(id); + auto v = actors.find(actor_id); if (v == actors.end()) { - Vertex new_vertex = add_vertex(Actor(actor_id), g); + auto new_vertex = add_vertex(Actor(actor_id), g); actors[actor_id] = new_vertex; actors_in_movie.push_back(new_vertex); } else { @@ -62,9 +62,9 @@ void load_actor_graph(std::istream& in, ActorGraph& g) } } - for (std::vector::iterator i = actors_in_movie.begin(); + for (auto i = actors_in_movie.begin(); i != actors_in_movie.end(); ++i) { - for (std::vector::iterator j = i + 1; + for (auto j = i + 1; j != actors_in_movie.end(); ++j) { if (!edge(*i, *j, g).second) add_edge(*i, *j, g); } @@ -78,14 +78,12 @@ write_pajek_graph(std::ostream& out, const Graph& g, VertexIndexMap vertex_index, VertexNameMap vertex_name) { out << "*Vertices " << num_vertices(g) << '\n'; - typedef typename graph_traits::vertex_iterator vertex_iterator; - for (vertex_iterator v = vertices(g).first; v != vertices(g).second; ++v) { + for (auto v = vertices(g).first; v != vertices(g).second; ++v) { out << get(vertex_index, *v)+1 << " \"" << get(vertex_name, *v) << "\"\n"; } out << "*Edges\n"; - typedef typename graph_traits::edge_iterator edge_iterator; - for (edge_iterator e = edges(g).first; e != edges(g).second; ++e) { + for (auto e = edges(g).first; e != edges(g).second; ++e) { out << get(vertex_index, source(*e, g))+1 << ' ' << get(vertex_index, target(*e, g))+1 << " 1.0\n"; // HACK! } diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index 6d805379..282c7cf5 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -59,10 +59,8 @@ int main(int , char* []) const int V = 5; Graph g(V); - property_map::type - id = get(&VertexProperties::index, g); - property_map::type - name = get(&EdgeProperties::name, g); + auto id = get(&VertexProperties::index, g); + auto name = get(&EdgeProperties::name, g); boost::graph_traits::vertex_iterator vi, viend; int vnum = 0; diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 48b3260f..77f2beb0 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -81,8 +81,8 @@ class distance_heuristic : public astar_heuristic : m_location(l), m_goal(goal) {} CostType operator()(Vertex u) { - CostType dx = m_location[m_goal].x - m_location[u].x; - CostType dy = m_location[m_goal].y - m_location[u].y; + auto dx = m_location[m_goal].x - m_location[u].x; + auto dy = m_location[m_goal].y - m_location[u].y; return ::sqrt(dx * dx + dy * dy); } private: @@ -160,7 +160,7 @@ int main(int argc, char **argv) // create graph mygraph_t g(N); - WeightMap weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); for(std::size_t j = 0; j < num_edges; ++j) { edge_descriptor e; bool inserted; boost::tie(e, inserted) = add_edge(edge_array[j].first, @@ -171,8 +171,8 @@ int main(int argc, char **argv) // pick random start/goal boost::mt19937 gen(time(0)); - vertex start = random_vertex(g, gen); - vertex goal = random_vertex(g, gen); + auto start = random_vertex(g, gen); + auto goal = random_vertex(g, gen); cout << "Start vertex: " << name[start] << endl; @@ -202,14 +202,14 @@ int main(int argc, char **argv) } catch(found_goal fg) { // found a path to the goal list shortest_path; - for(vertex v = goal;; v = p[v]) { + for(auto v = goal;; v = p[v]) { shortest_path.push_front(v); if(p[v] == v) break; } cout << "Shortest path from " << name[start] << " to " << name[goal] << ": "; - list::iterator spi = shortest_path.begin(); + auto spi = shortest_path.begin(); cout << name[start]; for(++spi; spi != shortest_path.end(); ++spi) cout << " -> " << name[*spi]; diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index fad2c208..973ed380 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -178,8 +178,8 @@ bool maze::solve() { dist_map distance; boost::associative_property_map dist_pmap(distance); - vertex_descriptor s = source(); - vertex_descriptor g = goal(); + auto s = source(); + auto g = goal(); euclidean_heuristic heuristic(g); astar_goal_visitor visitor(g); @@ -192,7 +192,7 @@ bool maze::solve() { } catch(found_goal fg) { // Walk backwards from the goal through the predecessor chain adding // vertices to the solution path. - for (vertex_descriptor u = g; u != s; u = predecessor[u]) + for (auto u = g; u != s; u = predecessor[u]) m_solution.insert(u); m_solution.insert(s); m_solution_length = distance[g]; @@ -256,9 +256,9 @@ std::size_t random_int(std::size_t a, std::size_t b) { // Generate a maze with a random assignment of barriers. maze random_maze(std::size_t x, std::size_t y) { maze m(x, y); - vertices_size_type n = num_vertices(m.m_grid); - vertex_descriptor s = m.source(); - vertex_descriptor g = m.goal(); + auto n = num_vertices(m.m_grid); + auto s = m.source(); + auto g = m.goal(); // One quarter of the cells in the maze should be barriers. int barriers = n/4; while (barriers > 0) { @@ -267,7 +267,7 @@ maze random_maze(std::size_t x, std::size_t y) { // Walls range up to one quarter the dimension length in this direction. vertices_size_type wall = random_int(1, m.length(direction)/4); // Create the wall while decrementing the total barrier count. - vertex_descriptor u = vertex(random_int(0, n-1), m.m_grid); + auto u = vertex(random_int(0, n-1), m.m_grid); while (wall) { // Start and goal spaces should never be barriers. if (u != s && u != g) { @@ -277,7 +277,7 @@ maze random_maze(std::size_t x, std::size_t y) { barriers--; } } - vertex_descriptor v = m.m_grid.next(u, direction); + auto v = m.m_grid.next(u, direction); // Stop creating this wall if we reached the maze's edge. if (u == v) break; diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index e6ec8750..34e13c27 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -27,8 +27,7 @@ struct edge_writer void operator() (std::ostream & out, const Edge & e) const { out << "[label=\"" << get(edge_weight, m_g, e) << "\""; - typename graph_traits < Graph >::vertex_descriptor - u = source(e, m_g), v = target(e, m_g); + auto u = source(e, m_g), v = target(e, m_g); if (m_parent[v] == u) out << ", color=\"black\""; else @@ -71,8 +70,7 @@ main() Graph g(edge_array, edge_array + n_edges, N); #endif graph_traits < Graph >::edge_iterator ei, ei_end; - property_map::type - weight_pmap = get(&EdgeProperties::weight, g); + auto weight_pmap = get(&EdgeProperties::weight, g); int i = 0; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) weight_pmap[*ei] = weight[i]; @@ -109,9 +107,8 @@ main() { for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - graph_traits < Graph >::edge_descriptor e = *ei; - graph_traits < Graph >::vertex_descriptor - u = source(e, g), v = target(e, g); + auto e = *ei; + auto u = source(e, g), v = target(e, g); // VC++ doesn't like the 3-argument get function, so here // we workaround by using 2-nested get()'s. dot_file << name[u] << " -> " << name[v] diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index bc5d92ab..2a5f92a8 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -69,7 +69,7 @@ main() Size time = 0; typedef property_map::type dtime_map_t; - dtime_map_t dtime_map = get(&VertexProps::discover_time, g); + auto dtime_map = get(&VertexProps::discover_time, g); bfs_time_visitor < dtime_map_t > vis(dtime_map, time); breadth_first_search(g, vertex(s, g), color_map(get(&VertexProps::color, g)). visitor(vis)); diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index aab408d9..e05cc9e9 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -17,16 +17,15 @@ void build_router_network(Graph & g, VertexNameMap name_map, TransDelayMap delay_map) { - typename graph_traits < Graph >::vertex_descriptor a, b, c, d, e; - a = add_vertex(g); + auto a = add_vertex(g); name_map[a] = 'a'; - b = add_vertex(g); + auto b = add_vertex(g); name_map[b] = 'b'; - c = add_vertex(g); + auto c = add_vertex(g); name_map[c] = 'c'; - d = add_vertex(g); + auto d = add_vertex(g); name_map[d] = 'd'; - e = add_vertex(g); + auto e = add_vertex(g); name_map[e] = 'e'; typename graph_traits::edge_descriptor ed; @@ -79,13 +78,13 @@ main() typedef adjacency_list < listS, vecS, directedS, VP, EP> graph_t; graph_t g; - property_map::type name_map = get(&VP::name, g); - property_map::type delay_map = get(&EP::weight, g); + auto name_map = get(&VP::name, g); + auto delay_map = get(&EP::weight, g); build_router_network(g, name_map, delay_map); typedef property_map::type VertexNameMap; - graph_traits::vertex_descriptor a = *vertices(g).first; + auto a = *vertices(g).first; bfs_name_printer vis(name_map); std::cout << "BFS vertex discover order: "; breadth_first_search(g, a, visitor(vis)); diff --git a/example/bfs.cpp b/example/bfs.cpp index 1f34c155..5df01d0f 100644 --- a/example/bfs.cpp +++ b/example/bfs.cpp @@ -129,7 +129,7 @@ int main(int , char* []) std::fill_n(d, 5, 0); // The source vertex - Vertex s = *(boost::vertices(G).first); + auto s = *(boost::vertices(G).first); p[s] = s; boost::breadth_first_search (G, s, diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index 050362f6..f6238310 100644 --- a/example/bfs_neighbor.cpp +++ b/example/bfs_neighbor.cpp @@ -123,7 +123,7 @@ int main(int , char* []) std::fill_n(d, 5, 0); // The source vertex - Vertex s = *(boost::vertices(G).first); + auto s = *(boost::vertices(G).first); p[s] = s; boost::neighbor_breadth_first_search (G, s, diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 0406dcba..dc09ca49 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -44,10 +44,9 @@ main() add_edge(6, 7, g); add_edge(7, 8, g); - property_map < graph_t, edge_component_t >::type - component = get(edge_component, g); + auto component = get(edge_component, g); - std::size_t num_comps = biconnected_components(g, component); + auto num_comps = biconnected_components(g, component); std::cerr << "Found " << num_comps << " biconnected components.\n"; std::vector art_points; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index 53da8263..c0377d2e 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -30,9 +30,8 @@ class calc_distance_visitor : public boost::bfs_visitor<> void tree_edge(typename boost::graph_traits::edge_descriptor e, Graph& g) { - typename boost::graph_traits::vertex_descriptor u, v; - u = boost::source(e, g); - v = boost::target(e, g); + auto u = boost::source(e, g); + auto v = boost::target(e, g); distance[v] = distance[u] + 1; } private: @@ -97,9 +96,8 @@ main() NameVertexMap name2vertex; Graph g; - typedef property_map::type NameMap; - NameMap node_name = get(vertex_name, g); - property_map::type link_name = get(edge_name, g); + auto node_name = get(vertex_name, g); + auto link_name = get(edge_name, g); //=========================================================================== // Read the data file and construct the graph. @@ -114,7 +112,7 @@ main() bool inserted; Vertex u, v; - std::list::iterator i = line_toks.begin(); + auto i = line_toks.begin(); boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { @@ -203,6 +201,8 @@ main() // the tree nodes in the order that we want to print out: // a directory-structure like format. std::vector dfs_distances(num_vertices(g), 0); + + using NameMap = property_map::type; print_tree_visitor tree_printer(node_name, &dfs_distances[0]); for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index dec3474f..482805c0 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -83,17 +83,15 @@ int main() property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; Graph g; - property_map < Graph, edge_capacity_t >::type - capacity = get(edge_capacity, g); - property_map < Graph, edge_residual_capacity_t >::type - residual_capacity = get(edge_residual_capacity, g); - property_map < Graph, edge_reverse_t >::type rev = get(edge_reverse, g); + auto capacity = get(edge_capacity, g); + auto residual_capacity = get(edge_residual_capacity, g); + auto rev = get(edge_reverse, g); Traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); std::vector color(num_vertices(g)); std::vector distance(num_vertices(g)); - long flow = boykov_kolmogorov_max_flow(g ,s, t); + auto flow = boykov_kolmogorov_max_flow(g ,s, t); std::cout << "c The total flow:" << std::endl; std::cout << "s " << flow << std::endl << std::endl; diff --git a/example/bron_kerbosch_clique_number.cpp b/example/bron_kerbosch_clique_number.cpp index 46b5c7a0..12ac3c90 100644 --- a/example/bron_kerbosch_clique_number.cpp +++ b/example/bron_kerbosch_clique_number.cpp @@ -28,7 +28,7 @@ main(int argc, char *argv[]) read_graph(g, cin); // Use the Bron-Kerbosch algorithm to find all cliques, and - size_t c = bron_kerbosch_clique_number(g); + auto c = bron_kerbosch_clique_number(g); cout << "clique number: " << c << endl; return 0; diff --git a/example/bucket_sorter.cpp b/example/bucket_sorter.cpp index 0b5ca055..c1751932 100644 --- a/example/bucket_sorter.cpp +++ b/example/bucket_sorter.cpp @@ -51,7 +51,7 @@ int main() { if ( ! my_bucket_sorter[j].empty() ) { cout << " has number "; do { - int v = my_bucket_sorter[j].top(); + auto v = my_bucket_sorter[j].top(); my_bucket_sorter[j].pop(); cout << v << " "; } while ( ! my_bucket_sorter[j].empty() ); @@ -74,7 +74,7 @@ int main() { if ( ! my_bucket_sorter[j].empty() ) { cout << " has number "; do { - int v = my_bucket_sorter[j].top(); + auto v = my_bucket_sorter[j].top(); my_bucket_sorter[j].pop(); cout << v << " "; } while ( ! my_bucket_sorter[j].empty() ); @@ -88,7 +88,7 @@ int main() { for (iii=0; iii::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) @@ -81,10 +81,9 @@ int main(int argc, char** argv) embedding.begin(), get(vertex_index, g)), std::back_inserter(ordering)); - ordering_storage_t::iterator oi, oi_end; - oi_end = ordering.end(); + auto oi_end = ordering.end(); std::cout << "The planar canonical ordering is: "; - for(oi = ordering.begin(); oi != oi_end; ++oi) + for(auto oi = ordering.begin(); oi != oi_end; ++oi) std::cout << *oi << " "; std::cout << std::endl; diff --git a/example/cc-internet.cpp b/example/cc-internet.cpp index 0f2d930b..2ce0f61e 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -25,8 +25,7 @@ main() (g, make_iterator_property_map(component.begin(), get(vertex_index, g), component[0])); - property_map < GraphvizGraph, vertex_attribute_t >::type - vertex_attr_map = get(vertex_attribute, g); + auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end; diff --git a/example/city_visitor.cpp b/example/city_visitor.cpp index 85415a6f..adf9f148 100644 --- a/example/city_visitor.cpp +++ b/example/city_visitor.cpp @@ -127,8 +127,7 @@ int main(int, char*[]) cout << endl; /* Get the source vertex */ - boost::graph_traits::vertex_descriptor - s = vertex(SanJose,G); + auto s = vertex(SanJose,G); cout << "*** Breadth First ***" << endl; breadth_first_search diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index c4a451f1..ad17ea2e 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -54,7 +54,7 @@ main(int argc, char *argv[]) // computation. ClusteringContainer coefs(num_vertices(g)); ClusteringMap cm(coefs, g); - float cc = all_clustering_coefficients(g, cm); + auto cc = all_clustering_coefficients(g, cm); // Print the clustering coefficient of each vertex. graph_traits::vertex_iterator i, end; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 15a83ca6..12702944 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -25,7 +25,7 @@ main() add_edge(2, 5, G); std::vector c(num_vertices(G)); - int num = connected_components + auto num = connected_components (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); std::cout << std::endl; diff --git a/example/connected_components.cpp b/example/connected_components.cpp index 0d9102bb..bca8b0e9 100644 --- a/example/connected_components.cpp +++ b/example/connected_components.cpp @@ -49,7 +49,7 @@ int main(int , char* []) add_edge(2, 5, G); std::vector component(num_vertices(G)); - int num = connected_components(G, &component[0]); + auto num = connected_components(G, &component[0]); std::vector::size_type i; cout << "Total number of components: " << num << endl; diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 572bb369..a78e036a 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -21,8 +21,7 @@ main() enum { a, b, c, d, e, f, g, N }; graph_t G(N); - property_map < graph_t, vertex_name_t >::type - name_map = get(vertex_name, G); + auto name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 23b0238d..ac26abba 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -61,25 +61,24 @@ int main(int , char* []) graph_traits::vertex_iterator ui, ui_end; - property_map::type deg = get(vertex_degree, G); + auto deg = get(vertex_degree, G); for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); - property_map::type - index_map = get(vertex_index, G); + auto index_map = get(vertex_index, G); std::cout << "original bandwidth: " << bandwidth(G) << std::endl; std::vector inv_perm(num_vertices(G)); std::vector perm(num_vertices(G)); { - Vertex s = vertex(6, G); + auto s = vertex(6, G); //reverse cuthill_mckee_ordering cuthill_mckee_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (std::vector::const_iterator i = inv_perm.begin(); + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -91,13 +90,13 @@ int main(int , char* []) << std::endl; } { - Vertex s = vertex(0, G); + auto s = vertex(0, G); //reverse cuthill_mckee_ordering cuthill_mckee_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (std::vector::const_iterator i=inv_perm.begin(); + for (auto i=inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -116,7 +115,7 @@ int main(int , char* []) cout << "Reverse Cuthill-McKee ordering:" << endl; cout << " "; - for (std::vector::const_iterator i=inv_perm.begin(); + for (auto i=inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; diff --git a/example/cycle_canceling_example.cpp b/example/cycle_canceling_example.cpp index 46e85f14..83fb66ac 100644 --- a/example/cycle_canceling_example.cpp +++ b/example/cycle_canceling_example.cpp @@ -21,7 +21,7 @@ int main() { boost::edmonds_karp_max_flow(g, s, t); boost::cycle_canceling(g); - int cost = boost::find_flow_cost(g); + auto cost = boost::find_flow_cost(g); assert(cost == 29); return 0; } diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index b65fdead..e08cc7f6 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -51,9 +51,9 @@ int main(int argc, char* argv[]) ccReal_t cc; ///critical cycle grap_real_t tgr; - property_map::type vim = get(vertex_index, tgr); - property_map::type ew1 = get(edge_weight, tgr); - property_map::type ew2 = get(edge_weight2, tgr); + auto vim = get(vertex_index, tgr); + auto ew1 = get(edge_weight, tgr); + auto ew2 = get(edge_weight2, tgr); gen_rand_graph(tgr, 1000, 30000); cout << "Vertices number: " << num_vertices(tgr) << endl; @@ -69,12 +69,12 @@ int main(int argc, char* argv[]) cout << "Minimum cycle ratio is " << min_cr << endl; std::pair cr(.0,.0); cout << "Critical cycle:\n"; - for (ccReal_t::iterator itr = cc.begin(); itr != cc.end(); ++itr) + for (const auto& edge : cc) { - cr.first += ew1[*itr]; - cr.second += ew2[*itr]; - std::cout << "(" << vim[source(*itr, tgr)] << "," << - vim[target(*itr, tgr)] << ") "; + cr.first += ew1[edge]; + cr.second += ew2[edge]; + std::cout << "(" << vim[source(edge, tgr)] << "," << + vim[target(edge, tgr)] << ") "; } cout << endl; assert(std::abs(cr.first / cr.second - min_cr) < epsilon); diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 97140c8e..93eec25a 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -41,8 +41,7 @@ int main() add_edge(u, x, 1, g); add_edge(v, x, -2, g); - property_map::type - d_map = get(vertex_distance, g); + auto d_map = get(vertex_distance, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ has trouble with the named-parameter mechanism, so @@ -52,7 +51,7 @@ int main() default_dijkstra_visitor vis; std::less compare; closed_plus combine; - property_map::type w_map = get(edge_weight, g); + auto w_map = get(edge_weight, g); dag_shortest_paths(g, s, d_map, w_map, &color[0], &pred[0], vis, compare, combine, (std::numeric_limits::max)(), 0); #else diff --git a/example/dave.cpp b/example/dave.cpp index 04c69f88..048dbd24 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -162,8 +162,7 @@ main(int , char* []) enum { a, b, c, d, e, f, g, N}; Graph G(N); - boost::property_map::type - vertex_id = get(vertex_index, G); + auto vertex_id = get(vertex_index, G); std::vector distance(N, (numeric_limits::max)()); typedef boost::graph_traits::vertex_descriptor Vertex; diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 500f9811..b6fffd46 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -38,23 +38,21 @@ main(int, char *[]) graph_traits::vertex_iterator i, iend; graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes); - property_map::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); // Manually intialize the vertex index and name maps - property_map::type indexmap = get(vertex_index, g); - property_map::type name = get(vertex_name, g); + auto indexmap = get(vertex_index, g); + auto name = get(vertex_name, g); int c = 0; for (boost::tie(i, iend) = vertices(g); i != iend; ++i, ++c) { indexmap[*i] = c; name[*i] = 'A' + c; } - vertex_descriptor s = vertex(A, g); + auto s = vertex(A, g); - property_map::type - d = get(vertex_distance, g); - property_map::type - p = get(vertex_predecessor, g); + auto d = get(vertex_distance, g); + auto p = get(vertex_predecessor, g); dijkstra_shortest_paths(g, s, predecessor_map(p).distance_map(d)); std::cout << "distances and parents:" << std::endl; @@ -75,9 +73,8 @@ main(int, char *[]) graph_traits < graph_t >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - graph_traits < graph_t >::edge_descriptor e = *ei; - graph_traits < graph_t >::vertex_descriptor - u = source(e, g), v = target(e, g); + auto e = *ei; + auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; if (p[v] == u) diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 269d2570..7a04ef39 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -33,10 +33,10 @@ main(int, char *[]) int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 }; int num_arcs = sizeof(edge_array) / sizeof(Edge); graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes); - property_map::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); std::vector p(num_vertices(g)); std::vector d(num_vertices(g)); - vertex_descriptor s = vertex(A, g); + auto s = vertex(A, g); dijkstra_shortest_paths(g, s, predecessor_map(boost::make_iterator_property_map(p.begin(), get(boost::vertex_index, g))). @@ -61,9 +61,8 @@ main(int, char *[]) graph_traits < graph_t >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - graph_traits < graph_t >::edge_descriptor e = *ei; - graph_traits < graph_t >::vertex_descriptor - u = source(e, g), v = target(e, g); + auto e = *ei; + auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; if (p[v] == u) diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index 14d196d9..78e8249c 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -37,10 +37,10 @@ main(int, char *[]) int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 }; int num_arcs = sizeof(edge_array) / sizeof(Edge); graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes); - property_map::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); std::vector p(num_vertices(g)); std::vector d(num_vertices(g)); - vertex_descriptor s = vertex(A, g); + auto s = vertex(A, g); dijkstra_shortest_paths_no_color_map(g, s, predecessor_map(boost::make_iterator_property_map(p.begin(), get(boost::vertex_index, g))). @@ -66,8 +66,7 @@ main(int, char *[]) graph_traits < graph_t >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits < graph_t >::edge_descriptor e = *ei; - graph_traits < graph_t >::vertex_descriptor - u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; if (p[v] == u) diff --git a/example/directed_graph.cpp b/example/directed_graph.cpp index bb308aa5..52aeca54 100644 --- a/example/directed_graph.cpp +++ b/example/directed_graph.cpp @@ -17,8 +17,8 @@ int main(int,char*[]) typedef boost::directed_graph<> Graph; Graph g; - boost::graph_traits::vertex_descriptor v0 = g.add_vertex(); - boost::graph_traits::vertex_descriptor v1 = g.add_vertex(); + auto v0 = g.add_vertex(); + auto v1 = g.add_vertex(); g.add_edge(v0, v1); diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index bd33ca72..3267b932 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -22,7 +22,7 @@ namespace boost { typename graph_traits < Graph >::vertex_descriptor p; typedef typename graph_traits < Graph >::degree_size_type size_type; - size_type delta = (std::numeric_limits < size_type >::max)(); + auto delta = (std::numeric_limits < size_type >::max)(); typename graph_traits < Graph >::vertex_iterator i, iend; for (boost::tie(i, iend) = vertices(g); i != iend; ++i) if (degree(*i, g) < delta) @@ -79,12 +79,9 @@ namespace boost std::vector < edge_descriptor > pred(num_vertices(g)); FlowGraph flow_g(num_vertices(g)); - typename property_map < FlowGraph, edge_capacity_t >::type - cap = get(edge_capacity, flow_g); - typename property_map < FlowGraph, edge_residual_capacity_t >::type - res_cap = get(edge_residual_capacity, flow_g); - typename property_map < FlowGraph, edge_reverse_t >::type - rev_edge = get(edge_reverse, flow_g); + auto cap = get(edge_capacity, flow_g); + auto res_cap = get(edge_residual_capacity, flow_g); + auto rev_edge = get(edge_reverse, flow_g); typename graph_traits < VertexListGraph >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { @@ -129,11 +126,10 @@ namespace boost } std::vector < bool > in_S_star(num_vertices(g), false); - typename std::vector < vertex_descriptor >::iterator si; - for (si = S_star.begin(); si != S_star.end(); ++si) + for (auto si = S_star.begin(); si != S_star.end(); ++si) in_S_star[*si] = true; degree_size_type c = 0; - for (si = S_star.begin(); si != S_star.end(); ++si) { + for (auto si = S_star.begin(); si != S_star.end(); ++si) { typename graph_traits < VertexListGraph >::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { @@ -155,18 +151,15 @@ main() read_graphviz("figs/edge-connectivity.dot", g); typedef graph_traits < GraphvizGraph >::edge_descriptor edge_descriptor; - typedef graph_traits < GraphvizGraph >::degree_size_type degree_size_type; std::vector < edge_descriptor > disconnecting_set; - degree_size_type c = - edge_connectivity(g, std::back_inserter(disconnecting_set)); + auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); std::cout << "The edge connectivity is " << c << "." << std::endl; - property_map < GraphvizGraph, vertex_attribute_t >::type - attr_map = get(vertex_attribute, g); + auto attr_map = get(vertex_attribute, g); std::cout << "The disconnecting set is {"; - for (std::vector < edge_descriptor >::iterator i = + for (auto i = disconnecting_set.begin(); i != disconnecting_set.end(); ++i) std:: cout << "(" << attr_map[source(*i, g)]["label"] << "," << diff --git a/example/edge-function.cpp b/example/edge-function.cpp index 6ee0b666..ca2b3abd 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -104,13 +104,13 @@ main() graph_traits < graph_type >::vertex_descriptor yow, zag, bar; // Get vertex name property map from the graph - typedef property_map < graph_type, vertex_name_t >::type name_map_t; - name_map_t name = get(vertex_name, g); + auto name = get(vertex_name, g); // Get iterators for the vertex set graph_traits < graph_type >::vertex_iterator i, end; boost::tie(i, end) = vertices(g); // Find yow.h - name_equals_t < name_map_t > predicate1("yow.h", name); + typedef property_map < graph_type, vertex_name_t >::type name_map_t; + name_equals_t predicate1("yow.h", name); yow = *std::find_if(i, end, predicate1); // Find zag.o name_equals_t < name_map_t > predicate2("zag.o", name); diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index 0d1d1152..ee7e7921 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -52,8 +52,8 @@ struct exercise_edge { // edge_traits class // Use the source() and target() functions to access the vertices // that belong to Edge e - Vertex src = source(e, G); - Vertex targ = target(e, G); + auto src = source(e, G); + auto targ = target(e, G); // print out the vertex id's just because cout << "(" << src << "," << targ << ") "; diff --git a/example/edge_connectivity.cpp b/example/edge_connectivity.cpp index 1e7535a2..da3dcd60 100644 --- a/example/edge_connectivity.cpp +++ b/example/edge_connectivity.cpp @@ -44,7 +44,7 @@ main() typedef graph_traits::degree_size_type degree_size_type; std::vector disconnecting_set; - degree_size_type c = edge_connectivity(g, std::back_inserter(disconnecting_set)); + auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); std::cout << "The edge connectivity is " << c << "." << std::endl; std::cout << "The disconnecting set is {"; diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index 95da715a..4a42357d 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -57,7 +57,7 @@ class edge_stream_iterator { return *this; } edge_stream_iterator operator++(int) { - edge_stream_iterator tmp = *this; + auto tmp = *this; m_read(); return tmp; } diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 879e7570..1a152984 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -76,10 +76,8 @@ void print_network(const Graph& G) typedef typename boost::graph_traits::out_edge_iterator OutEdgeIter; typedef typename boost::graph_traits::in_edge_iterator InEdgeIter; - typename property_map::const_type - capacity = get(edge_mycapacity, G); - typename property_map::const_type - flow = get(edge_myflow, G); + auto capacity = get(edge_mycapacity, G); + auto flow = get(edge_myflow, G); Viter ui, uiend; boost::tie(ui, uiend) = vertices(G); diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index 688cb674..38060972 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -56,11 +56,9 @@ main() Graph g; - property_map < Graph, edge_capacity_t >::type - capacity = get(edge_capacity, g); - property_map < Graph, edge_reverse_t >::type rev = get(edge_reverse, g); - property_map < Graph, edge_residual_capacity_t >::type - residual_capacity = get(edge_residual_capacity, g); + auto capacity = get(edge_capacity, g); + auto rev = get(edge_reverse, g); + auto residual_capacity = get(edge_residual_capacity, g); Traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); diff --git a/example/family_tree.cpp b/example/family_tree.cpp index c3623935..7aaabccf 100644 --- a/example/family_tree.cpp +++ b/example/family_tree.cpp @@ -29,10 +29,9 @@ main() add_edge(Rick, Margaret, g); add_edge(John, Benjamin, g); - graph_traits < adjacency_list <> >::vertex_iterator i, end; - graph_traits < adjacency_list <> >::adjacency_iterator ai, a_end; - property_map < adjacency_list <>, vertex_index_t >::type - index_map = get(vertex_index, g); + graph_traits>::vertex_iterator i, end; + graph_traits>::adjacency_iterator ai, a_end; + auto index_map = get(vertex_index, g); for (boost::tie(i, end) = vertices(g); i != end; ++i) { std::cout << name[get(index_map, *i)]; diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 226dfd29..e86c00ea 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -34,8 +34,7 @@ main() enum { a, b, c, d, e, f, g, N }; graph_t G(N); - property_map < graph_t, vertex_name_t >::type - name_map = get(vertex_name, G); + auto name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index eb140f64..9ac5f0d4 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -41,9 +41,8 @@ int main() { using namespace boost; - typedef adjacency_list > Graph; - typedef property_map::type EdgeWeightMap; + using Graph = adjacency_list>; enum { A, B, C, D, E, N }; const char* name = "ABCDE"; @@ -57,7 +56,7 @@ int main() add_edge(D, B, 3, g); add_edge(E, C, 0, g); - EdgeWeightMap weight = get(edge_weight, g); + auto weight = get(edge_weight, g); std::cout << "unfiltered edge_range(C,D)\n"; graph_traits::out_edge_iterator f, l; diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index ceb8a235..c01dd6e8 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -48,13 +48,13 @@ void merge_vertex typename Traits::out_edge_iterator out_i, out_end; for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; - typename Traits::vertex_descriptor targ = target(e, g); + auto targ = target(e, g); add_edge(u, targ, getp(e), g); } typename Traits::in_edge_iterator in_i, in_end; for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { e = *in_i; - typename Traits::vertex_descriptor src = source(e, g); + auto src = source(e, g); add_edge(src, u, getp(e), g); } clear_vertex(v, g); @@ -121,8 +121,8 @@ main() add_edge(3, 4, EdgeProperty('h'), g); add_edge(0, 1, EdgeProperty('c'), g); - property_map::type id = get(vertex_index, g); - property_map::type name = get(edge_name, g); + auto id = get(vertex_index, g); + auto name = get(edge_name, g); graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; diff --git a/example/girth.cpp b/example/girth.cpp index 9c9cc23c..728c5739 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -72,14 +72,14 @@ class diameter_and_girth_visitor : public boost::bfs_visitor<> : k(k_), girth(girth_) { } void tree_edge(edge_descriptor e, Graph* g) { - vertex_descriptor u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); k = d_map[u] + 1; d_map[v] = k; ++distance_list[k]; p_map[v] = u; } void non_tree_edge(edge_descriptor e, Graph* g) { - vertex_descriptor u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); k = d_map[u] + 1; if (d_map[v] + k < girth && v != p_map[u]) girth = d_map[v]+ k; diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index 748d385d..648149a9 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -47,20 +47,16 @@ int main() { graph_t graph(0); dynamic_properties dp; - property_map::type vname = - get(vertex_name, graph); + auto vname = get(vertex_name, graph); dp.property("node_id",vname); - property_map::type vlabel = - get(vertex_label_t(), graph); + auto vlabel = get(vertex_label_t(), graph); dp.property("label",vlabel); - property_map::type root = - get(vertex_root, graph); + auto root = get(vertex_root, graph); dp.property("root",root); - property_map::type elabel = - get(edge_name, graph); + auto elabel = get(edge_name, graph); dp.property("label",elabel); // Use ref_property_map to turn a graph property into a property map diff --git a/example/graph_as_tree.cpp b/example/graph_as_tree.cpp index 635cd179..03677106 100644 --- a/example/graph_as_tree.cpp +++ b/example/graph_as_tree.cpp @@ -39,15 +39,14 @@ int main() graph_t g; - vertex_t a = add_vertex(g), + auto a = add_vertex(g), b = add_vertex(g), c = add_vertex(g); add_edge(a, b, g); add_edge(a, c, g); - typedef property_map::type vertex_name_map_t; - vertex_name_map_t name = get(vertex_name, g); + auto name = get(vertex_name, g); name[a] = "A"; name[b] = "B"; name[c] = "C"; diff --git a/example/grid_graph_properties.cpp b/example/grid_graph_properties.cpp index 37d252a8..437f1216 100644 --- a/example/grid_graph_properties.cpp +++ b/example/grid_graph_properties.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) put(dataMap, v, 2.0f); // Get the data at the node at position (0,1) in the grid - float retrieved = get(dataMap, v); + auto retrieved = get(dataMap, v); std::cout << "Retrieved value: " << retrieved << std::endl; return 0; diff --git a/example/hawick_circuits.cpp b/example/hawick_circuits.cpp index b29467b9..a861fc1f 100644 --- a/example/hawick_circuits.cpp +++ b/example/hawick_circuits.cpp @@ -32,11 +32,7 @@ struct cycle_printer // Get the property map containing the vertex indices // so we can print them. - typedef typename boost::property_map< - Graph, boost::vertex_index_t - >::const_type IndexMap; - - IndexMap indices = get(boost::vertex_index, g); + auto indices = get(boost::vertex_index, g); // Iterate over path printing each vertex that forms the cycle. typename Path::const_iterator i, before_end = boost::prior(p.end()); diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index 0d788735..8ca1f5a6 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -217,7 +217,7 @@ class ring_incident_edge_iterator:public boost::iterator_adaptor < static const int ring_offset[] = {1, -1}; vertex_descriptor v; - std::size_t p = *this->base_reference(); + auto p = *this->base_reference(); if (m_u == 0 && p == 1) v = m_n-1; // Vertex n-1 precedes vertex 0. else diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index e7d26f13..43538168 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -63,7 +63,7 @@ main(int argc, char *argv[]) // Print the degree centrality of each vertex graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - Vertex v = *i; + auto v = *i; cout << setiosflags(ios::left) << setw(12) << g[v].name << "\t" << im[v] << "\t" diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 7083d663..fbe21f93 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -57,7 +57,7 @@ void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) // Access the propety acessor type for this graph typedef typename property_map ::const_type NamePA; - NamePA name = get(vertex_first_name, G); + auto name = get(vertex_first_name, G); typedef typename boost::property_traits::value_type NameType; diff --git a/example/iteration_macros.cpp b/example/iteration_macros.cpp index 27451f96..a0524221 100644 --- a/example/iteration_macros.cpp +++ b/example/iteration_macros.cpp @@ -31,8 +31,7 @@ int main() graph_traits >::vertex_iterator i, end; graph_traits >::adjacency_iterator ai, a_end; - property_map, vertex_index_t>::type - index_map = get(vertex_index, g); + auto index_map = get(vertex_index, g); BGL_FORALL_VERTICES(i, g, adjacency_list<>) { std::cout << name[get(index_map, i)]; diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 557b1733..059400b9 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -38,7 +38,7 @@ main() Graph g(edge_array, edge_array + E, V); #endif - property_map < Graph, edge_weight_t >::type w = get(edge_weight, g); + auto w = get(edge_weight, g); int weights[] = { 0, 0, 0, 0, 0, 3, -4, 8, 1, 7, 4, -5, 2, 6 }; int *wp = weights; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 5b1dd8b5..8d35b195 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -57,10 +57,8 @@ main() std::string >, property < edge_name_t, std::string > > Graph; Graph g; - typedef property_map < Graph, vertex_name_t >::type actor_name_map_t; - actor_name_map_t actor_name = get(vertex_name, g); - typedef property_map < Graph, edge_name_t >::type movie_name_map_t; - movie_name_map_t connecting_movie = get(edge_name, g); + auto actor_name = get(vertex_name, g); + auto connecting_movie = get(edge_name, g); typedef graph_traits < Graph >::vertex_descriptor Vertex; typedef std::map < std::string, Vertex > NameVertexMap; diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index 2cd17838..4532d25a 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -49,7 +49,7 @@ class bacon_number_recorder : public default_bfs_visitor bacon_number_recorder(int* dist) : d(dist) { } void tree_edge(Edge e, const Graph& g) const { - Vertex u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); d[v] = d[u] + 1; } private: diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 2b081fa2..73babf4c 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -61,25 +61,24 @@ int main(int , char* []) graph_traits::vertex_iterator ui, ui_end; - property_map::type deg = get(vertex_degree, G); + auto deg = get(vertex_degree, G); for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); - property_map::type - index_map = get(vertex_index, G); + auto index_map = get(vertex_index, G); std::cout << "original bandwidth: " << bandwidth(G) << std::endl; std::vector inv_perm(num_vertices(G)); std::vector perm(num_vertices(G)); { - Vertex s = vertex(6, G); + auto s = vertex(6, G); //king_ordering king_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G), get(vertex_index, G)); cout << "King ordering starting at: " << s << endl; cout << " "; - for (std::vector::const_iterator i = inv_perm.begin(); + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -97,7 +96,7 @@ int main(int , char* []) get(vertex_degree, G), get(vertex_index, G)); cout << "King ordering starting at: " << s << endl; cout << " "; - for (std::vector::const_iterator i=inv_perm.begin(); + for (auto i=inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -116,7 +115,7 @@ int main(int , char* []) cout << "King ordering:" << endl; cout << " "; - for (std::vector::const_iterator i=inv_perm.begin(); + for (auto i=inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 64297768..0307e9d2 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -27,7 +27,7 @@ main() std::size_t num_edges = sizeof(edge_array) / sizeof(E); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(num_nodes); - property_map::type weightmap = get(edge_weight, g); + auto = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { Edge e; bool inserted; boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); @@ -36,13 +36,13 @@ main() #else Graph g(edge_array, edge_array + num_edges, weights, num_nodes); #endif - property_map < Graph, edge_weight_t >::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); std::vector < Edge > spanning_tree; kruskal_minimum_spanning_tree(g, std::back_inserter(spanning_tree)); std::cout << "Print the edges in the MST:" << std::endl; - for (std::vector < Edge >::iterator ei = spanning_tree.begin(); + for (auto ei = spanning_tree.begin(); ei != spanning_tree.end(); ++ei) { std::cout << source(*ei, g) << " <--> " << target(*ei, g) << " with weight of " << weight[*ei] diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 7e53d70a..085cd36a 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -22,8 +22,7 @@ main() typedef adjacency_list < vecS, vecS, undirectedS, no_property, property < edge_weight_t, int > > Graph; Graph g(num_vertices(g_dot)); - property_map < GraphvizGraph, edge_attribute_t >::type - edge_attr_map = get(edge_attribute, g_dot); + auto edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); @@ -35,7 +34,7 @@ main() typedef std::vector < graph_traits < Graph >::edge_descriptor >::size_type size_type; kruskal_minimum_spanning_tree(g, std::back_inserter(mst)); - property_map < Graph, edge_weight_t >::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); int total_weight = 0; for (size_type e = 0; e < mst.size(); ++e) total_weight += get(weight, mst[e]); @@ -43,12 +42,11 @@ main() typedef graph_traits < Graph >::vertex_descriptor Vertex; for (size_type i = 0; i < mst.size(); ++i) { - Vertex u = source(mst[i], g), v = target(mst[i], g); + auto u = source(mst[i], g), v = target(mst[i], g); edge_attr_map[edge(u, v, g_dot).first]["color"] = "black"; } std::ofstream out("figs/telephone-mst-kruskal.dot"); - graph_property < GraphvizGraph, graph_edge_attribute_t >::type & - graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); + auto graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); graph_edge_attr_map["color"] = "gray"; graph_edge_attr_map["style"] = "bold"; write_graphviz(out, g_dot); diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index 8f55a3e6..bf8447ac 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -52,7 +52,7 @@ int main(int argc, char** argv) // Initialize the interior edge index - property_map::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index 4788dd72..4fcd1a1e 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -57,8 +57,7 @@ main() exit(-1); } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); // Create storage for last modified times @@ -69,7 +68,7 @@ main() // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); - property_map < graph_type, vertex_name_t >::type name = get(vertex_name, g); + auto name = get(vertex_name, g); struct stat stat_buf; graph_traits < graph_type >::vertex_descriptor u; typedef graph_traits < graph_type >::vertex_iterator vertex_iter_t; diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index 4fddab84..3ca3a4f8 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -20,7 +20,7 @@ main() g.new_node("Eurystheus"); g.new_node("Amphitryon"); typedef property_map < graph_t, vertex_all_t >::type NodeMap; - NodeMap node_name_map = get(vertex_all, g); + auto node_name_map = get(vertex_all, g); graph_traits < graph_t >::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << node_name_map[*vi] << std::endl; diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 4bc66004..52d7f78a 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -124,17 +124,17 @@ main(int argc, char *argv[]) typedef std::set < Vertex > set_t; typedef std::list < set_t > list_of_sets_t; list_of_sets_t loops; - Vertex entry = *vertices(g).first; + auto entry = *vertices(g).first; find_loops(entry, g, loops); - property_map::type vattr_map = get(vertex_attribute, g); - property_map::type eattr_map = get(edge_attribute, g); + auto vattr_map = get(vertex_attribute, g); + auto eattr_map = get(edge_attribute, g); graph_traits < Graph >::edge_iterator ei, ei_end; - for (list_of_sets_t::iterator i = loops.begin(); i != loops.end(); ++i) { + for (auto i = loops.begin(); i != loops.end(); ++i) { std::vector < bool > in_loop(num_vertices(g), false); - for (set_t::iterator j = (*i).begin(); j != (*i).end(); ++j) { + for (auto j = (*i).begin(); j != (*i).end(); ++j) { vattr_map[*j]["color"] = "gray"; in_loop[*j] = true; } @@ -153,7 +153,7 @@ main(int argc, char *argv[]) graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; - for (std::map::iterator ai = vattr_map[*vi].begin(); + for (auto ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { loops_out << ai->first << "=" << ai->second; if (next(ai) != vattr_map[*vi].end()) @@ -164,8 +164,8 @@ main(int argc, char *argv[]) for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; - std::map& attr_map = eattr_map[*ei]; - for (std::map::iterator eai = attr_map.begin(); + auto& attr_map = eattr_map[*ei]; + for (auto eai = attr_map.begin(); eai != attr_map.end(); ++eai) { loops_out << eai->first << "=" << eai->second; if (next(eai) != attr_map.end()) diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index d0c0dd8e..f0c27e19 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv) //Initialize the interior edge index - property_map::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index 50d42e8d..86b6cfa8 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -71,7 +71,7 @@ int main(int argc, char** argv) << 2*num_vertices(g) - 4 << " faces." << std::endl; //Initialize the interior edge index - property_map::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) diff --git a/example/matching_example.cpp b/example/matching_example.cpp index de39f57c..d38c0006 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -76,7 +76,7 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for(std::vector::iterator itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) + for (auto itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) std::cout << *itr << std::endl; std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) << std::endl; @@ -103,7 +103,7 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for(std::vector::iterator itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) + for (auto itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) std::cout << *itr << std::endl; std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) << std::endl; diff --git a/example/max_flow.cpp b/example/max_flow.cpp index fc9f17c1..05249540 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -59,12 +59,9 @@ main() Graph g; - property_map::type - capacity = get(edge_capacity, g); - property_map::type - rev = get(edge_reverse, g); - property_map::type - residual_capacity = get(edge_residual_capacity, g); + auto capacity = get(edge_capacity, g); + auto rev = get(edge_reverse, g); + auto residual_capacity = get(edge_residual_capacity, g); Traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); diff --git a/example/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index 543259fc..d49d1424 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -76,14 +76,12 @@ int main (int argc, char *argv[]) { property >, property > Graph; - typedef property_map::type VertexNameMap; - // Test maximum and unique variants on known graphs Graph graph_simple1, graph_simple2; example_callback user_callback(graph_simple1); - VertexNameMap vname_map_simple1 = get(vertex_name, graph_simple1); - VertexNameMap vname_map_simple2 = get(vertex_name, graph_simple2); + auto vname_map_simple1 = get(vertex_name, graph_simple1); + auto vname_map_simple2 = get(vertex_name, graph_simple2); // Graph that looks like a triangle put(vname_map_simple1, add_vertex(graph_simple1), 1); diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index ca246b0a..55e3262a 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -72,7 +72,7 @@ main(int argc, char *argv[]) // so-called small-world distance) as a result. GeodesicContainer geodesics(num_vertices(g)); GeodesicMap gm(geodesics, g); - float sw = all_mean_geodesics(g, dm, gm); + auto sw = all_mean_geodesics(g, dm, gm); // Print the mean geodesic distance of each vertex and finally, // the graph itself. diff --git a/example/miles_span.cpp b/example/miles_span.cpp index e9058673..81ca43c1 100644 --- a/example/miles_span.cpp +++ b/example/miles_span.cpp @@ -85,11 +85,9 @@ int main(int argc, char* argv[]) long sp_length = 0; // Use the "z" utility field for distance. - typedef property_map >::type Distance; - Distance d = get(z_property(), g); + auto d = get(z_property(), g); // Use the "w" property for parent - typedef property_map >::type Parent; - Parent p = get(w_property(), g); + auto p = get(w_property(), g); total_length_visitor length_vis(sp_length, d); prim_minimum_spanning_tree(g, p, diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index f32dd76e..7c53394f 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -58,7 +58,7 @@ main(int , char* []) #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle iterator constructors Graph G(num_nodes); - property_map::type weightmap = get(edge_weight, G); + auto weightmap = get(edge_weight, G); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); @@ -66,7 +66,7 @@ main(int , char* []) } #else Graph G(edges, edges + n_edges, weights, num_nodes); - property_map::type weightmap = get(edge_weight, G); + auto weightmap = get(edge_weight, G); #endif std::vector p(num_vertices(G)); diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index a7b1963a..cc3ca770 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -129,8 +129,7 @@ int main(int argc, char* argv[]) Vector supernode_sizes(n, 1); // init has to be 1 - boost::property_map::type - id = get(vertex_index, G); + auto id = get(vertex_index, G); Vector degree(n, 0); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 42b668cb..358c69a6 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -46,8 +46,7 @@ void modify_demo(MutableGraph& g) typename GraphTraits::edges_size_type m = 0; typename GraphTraits::vertex_descriptor u, v, w; edge_descriptor e, e1, e2; - typename property_map::type - name_map = get(edge_name, g); + auto name_map = get(edge_name, g); bool added; typename GraphTraits::vertex_iterator vi, vi_end; diff --git a/example/neighbor_bfs.cpp b/example/neighbor_bfs.cpp index 7b3e339a..a70e33c2 100644 --- a/example/neighbor_bfs.cpp +++ b/example/neighbor_bfs.cpp @@ -62,16 +62,14 @@ class distance_and_pred_visitor : public neighbor_bfs_visitor<> template void tree_out_edge(Edge e, const Graph& g) const { - typename graph_traits::vertex_descriptor - u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); put(m_distance, v, get(m_distance, u) + 1); put(m_predecessor, v, u); } template void tree_in_edge(Edge e, const Graph& g) const { - typename graph_traits::vertex_descriptor - u = source(e, g), v = target(e, g); + auto u = source(e, g), v = target(e, g); put(m_distance, u, get(m_distance, v) + 1); put(m_predecessor, u, v); } diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 5c45373a..8cbc40a4 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -90,8 +90,8 @@ main() add_edge(3, 4, EdgeProperty("harry"), g); add_edge(0, 1, EdgeProperty("chandler"), g); - property_map::type id = get(vertex_index, g); - property_map::type name = get(edge_name, g); + auto id = get(vertex_index, g); + auto name = get(edge_name, g); graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 3d0e53b7..e4647527 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -44,7 +44,7 @@ main() Graph g(num_vertices(g_dot)); graph_traits < g_dot_type >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - int weight = get(edge_weight, g_dot, *ei); + auto weight = get(edge_weight, g_dot, *ei); property < edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } @@ -65,8 +65,8 @@ main() #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 std::vector distance(num_vertices(g)); - property_map::type weightmap = get(edge_weight, g); - property_map::type indexmap = get(vertex_index, g); + auto weightmap = get(edge_weight, g); + auto indexmap = get(vertex_index, g); dijkstra_shortest_paths (g, router_six, &parent[0], &distance[0], weightmap, indexmap, std::less(), closed_plus(), diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index fe96d2de..c24a07dc 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -91,7 +91,7 @@ int main(int argc, char** argv) // Initialize the interior edge index - property_map::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) diff --git a/example/prim-example.cpp b/example/prim-example.cpp index b36740bf..3d1dbf39 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -24,7 +24,7 @@ main() int weights[] = { 1, 1, 2, 7, 3, 1, 1 }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(num_nodes); - property_map::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); @@ -37,8 +37,8 @@ main() p(num_vertices(g)); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map::type distance = get(vertex_distance, g); - property_map::type indexmap = get(vertex_index, g); + auto distance = get(vertex_distance, g); + auto indexmap = get(vertex_index, g); prim_minimum_spanning_tree (g, *vertices(g).first, &p[0], distance, weightmap, indexmap, default_dijkstra_visitor()); diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 319940d3..69d21983 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -22,20 +22,19 @@ main() typedef adjacency_list < vecS, vecS, undirectedS, no_property, property < edge_weight_t, int > > Graph; Graph g(num_vertices(g_dot)); - property_map < GraphvizGraph, edge_attribute_t >::type - edge_attr_map = get(edge_attribute, g_dot); + auto edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); + auto weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); property < edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } typedef graph_traits < Graph >::vertex_descriptor Vertex; std::vector < Vertex > parent(num_vertices(g)); - property_map < Graph, edge_weight_t >::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map::type indexmap = get(vertex_index, g); + auto indexmap = get(vertex_index, g); std::vector distance(num_vertices(g)); prim_minimum_spanning_tree(g, *vertices(g).first, &parent[0], &distance[0], weight, indexmap, default_dijkstra_visitor()); diff --git a/example/property-map-traits-eg.cpp b/example/property-map-traits-eg.cpp index c82ab19c..c136e82e 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -17,8 +17,7 @@ main() property < vertex_name_t, std::string > >graph_t; graph_t g; graph_traits < graph_t >::vertex_descriptor u = add_vertex(g); - property_map < graph_t, vertex_name_t >::type - name_map = get(vertex_name, g); + auto name_map = get(vertex_name, g); name_map[u] = "Joe"; std::cout << name_map[u] << std::endl; return EXIT_SUCCESS; diff --git a/example/property_iterator.cpp b/example/property_iterator.cpp index d8e61cc3..6a5a1348 100644 --- a/example/property_iterator.cpp +++ b/example/property_iterator.cpp @@ -94,14 +94,12 @@ int main(int argc, char* argv[]) std::cout << write( graph ); std::cout << "radii:" << std::endl; - graph_property_iter_range::type - seqRadius = get_property_iter_range(graph,radius_t()); + auto seqRadius = get_property_iter_range(graph,radius_t()); std::for_each( seqRadius.first, seqRadius.second, Print() ); std::cout << std::endl; std::cout << "stiff:" << std::endl; - graph_property_iter_range::type - seqStiff = get_property_iter_range(graph, stiff_t()); + auto seqStiff = get_property_iter_range(graph, stiff_t()); std::for_each( seqStiff.first, seqStiff.second, Print() ); std::cout << std::endl; diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index 407045f5..6c92bca4 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -54,16 +54,14 @@ main() property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; Graph g; - property_map < Graph, edge_capacity_t >::type - capacity = get(edge_capacity, g); - property_map < Graph, edge_residual_capacity_t >::type - residual_capacity = get(edge_residual_capacity, g); - property_map < Graph, edge_reverse_t >::type rev = get(edge_reverse, g); + auto capacity = get(edge_capacity, g); + auto residual_capacity = get(edge_residual_capacity, g); + auto rev = get(edge_reverse, g); Traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map::type indexmap = get(vertex_index, g); + auto indexmap = get(vertex_index, g); long flow = push_relabel_max_flow(g, s, t, capacity, residual_capacity, rev, indexmap); #else diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 31ffb606..396fceab 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -33,7 +33,7 @@ print_vertex_names(const Graph & g, VertexNameMap name_map) { std::cout << "vertices(g) = { "; typedef typename graph_traits < Graph >::vertex_iterator iter_t; - for (std::pair < iter_t, iter_t > p = vertices(g); p.first != p.second; + for (auto p = vertices(g); p.first != p.second; ++p.first) { print_vertex_name(*p.first, name_map); std::cout << ' '; @@ -97,10 +97,8 @@ main() property < edge_weight_t, double > > graph_t; graph_t g; - property_map < graph_t, vertex_name_t >::type name_map = - get(vertex_name, g); - property_map < graph_t, edge_weight_t >::type delay_map = - get(edge_weight, g); + auto name_map = get(vertex_name, g); + auto delay_map = get(edge_weight, g); build_router_network(g, name_map, delay_map); print_vertex_names(g, name_map); diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index e639fc5a..34644fc3 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -23,8 +23,7 @@ template struct exercise_vertex { void operator()(const Vertex& v) const { using namespace boost; - typename property_map::type - vertex_id = get(vertex_index, g); + auto vertex_id = get(vertex_index, g); std::cout << "vertex: " << name[get(vertex_id, v)] << std::endl; // Write out the outgoing edges @@ -35,7 +34,7 @@ template struct exercise_vertex { out_i != out_end; ++out_i) { e = *out_i; - Vertex src = source(e, g), targ = target(e, g); + auto src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; } @@ -90,7 +89,7 @@ int main(int,char*[]) #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor Graph g(num_vertices); - property_map::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { graph_traits::edge_descriptor e; bool inserted; boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 2183eab1..e295571d 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -34,8 +34,7 @@ main(int argc, char *argv[]) make_iterator_property_map(reachable_from_head.begin(), get(vertex_index, g), c)); - property_map::type - vattr_map = get(vertex_attribute, g); + auto vattr_map = get(vertex_attribute, g); graph_traits < GraphvizDigraph >::vertex_iterator i, i_end; for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) @@ -54,7 +53,7 @@ main(int argc, char *argv[]) graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; - for (std::map::iterator ai = vattr_map[*vi].begin(); + for (auto ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { loops_out << ai->first << "=" << ai->second; if (next(ai) != vattr_map[*vi].end()) @@ -68,7 +67,7 @@ main(int argc, char *argv[]) for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; std::map& attr_map = eattr_map[*ei]; - for (std::map::iterator eai = attr_map.begin(); + for (auto eai = attr_map.begin(); eai != attr_map.end(); ++eai) { loops_out << eai->first << "=" << eai->second; if (next(eai) != attr_map.end()) diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index a723d143..8e4e3efe 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -47,9 +47,8 @@ main(int argc, char *argv[]) << " graph [ratio=\"fill\",size=\"3,3\"];\n" << " node [shape=\"box\"];\n" << " edge [style=\"bold\"];\n"; - property_map::type - vattr_map = get(vertex_attribute, g); - graph_traits < GraphvizDigraph >::vertex_iterator i, i_end; + auto vattr_map = get(vertex_attribute, g); + graph_traits::vertex_iterator i, i_end; for (boost::tie(i, i_end) = vertices(g_in); i != i_end; ++i) { loops_out << *i << "[label=\"" << vattr_map[*i]["label"] << "\""; diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index 8750e9dc..a371e0a5 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -34,16 +34,13 @@ int main() { graph_t graph(0); dynamic_properties dp; - property_map::type name = - get(vertex_name, graph); + auto name = get(vertex_name, graph); dp.property("node_id",name); - property_map::type mass = - get(vertex_color, graph); + auto mass = get(vertex_color, graph); dp.property("mass",mass); - property_map::type weight = - get(edge_weight, graph); + auto weight = get(edge_weight, graph); dp.property("weight",weight); // Use ref_property_map to turn a graph property into a property map diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 64ac43b7..dd653814 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -76,10 +76,8 @@ int main() typedef property_map < Graph, edge_capacity_t >::type tCapMap; typedef tCapMap::value_type tCapMapValue; - typedef property_map < Graph, edge_reverse_t >::type tRevEdgeMap; - - tCapMap capacity = get(edge_capacity, g); - tRevEdgeMap rev = get(edge_reverse, g); + auto capacity = get(edge_capacity, g); + auto rev = get(edge_reverse, g); vertex_descriptor s, t; /*reading the graph from stdin*/ @@ -91,14 +89,14 @@ int main() //we take the source node and check for each outgoing edge e which has a target(p) if we can augment that path out_edge_iterator oei,oe_end; for(boost::tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ - edge_descriptor from_source = *oei; - vertex_descriptor v = target(from_source, g); + auto from_source = *oei; + auto v = target(from_source, g); edge_descriptor to_sink; bool is_there; boost::tie(to_sink, is_there) = edge(v, t, g); if( is_there ){ if( get(capacity, to_sink) > get(capacity, from_source) ){ - tCapMapValue to_augment = get(capacity, from_source); + auto to_augment = get(capacity, from_source); capacity[from_source] = 0; capacity[to_sink] -= to_augment; augmented_flow += to_augment; diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 9b7ef69f..4b40435d 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -47,7 +47,7 @@ struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } bool operator()(graph_traits::edge_descriptor e) { #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); return get(weight, e) > w; #else // This version of get() breaks VC++ @@ -82,7 +82,7 @@ main() for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; - property_map::type indexmap = get(vertex_index, g); + auto indexmap = get(vertex_index, g); std::cout << "original graph:" << std::endl; print_graph(g, indexmap); diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 3fc5b571..cfd13fdf 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -46,7 +46,7 @@ struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } bool operator()(graph_traits::edge_descriptor e) { #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); return get(weight, e) > w; #else // This version of get breaks VC++ diff --git a/example/roget_components.cpp b/example/roget_components.cpp index 8a34f22e..ce775fd1 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -56,11 +56,9 @@ int main(int argc, char* argv[]) // a separate field for marking colors, so we use the w field. std::vector comp(num_vertices(g)); - property_map::type - index_map = get(vertex_index, g); + auto index_map = get(vertex_index, g); - property_map >::type - root = get(v_property(), g); + auto root = get(v_property(), g); int num_comp = strong_components (g, make_iterator_property_map(comp.begin(), index_map), @@ -118,8 +116,8 @@ int main(int argc, char* argv[]) vertex_t v = strong_comp[c][i]; graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { - vertex_t x = target(*ei, g); - int comp_x = comp[index_map[x]]; + auto x = target(*ei, g); + auto comp_x = comp[index_map[x]]; if (comp_x != c && mark[comp_x] != c) { mark[comp_x] = c; vertex_t w = strong_comp[comp_x][0]; diff --git a/example/scc.cpp b/example/scc.cpp index e34fe582..902b024a 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -24,8 +24,7 @@ main() strong_components(g, make_assoc_property_map(component)); - property_map < GraphvizDigraph, vertex_attribute_t >::type - vertex_attr_map = get(vertex_attribute, g); + auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits < GraphvizDigraph >::vertex_iterator vi, vi_end; diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index e53e3552..19b45198 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -117,12 +117,12 @@ int main(int , char* []) graph_traits::vertex_iterator ui, ui_end; //Creating a property_map with the degrees of the degrees of each vertex - property_map::type deg = get(vertex_degree, G); + auto deg = get(vertex_degree, G); for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); //Creating a property_map for the indices of a vertex - property_map::type index_map = get(vertex_index, G); + auto index_map = get(vertex_index, G); std::cout << "original bandwidth: " << bandwidth(G) << std::endl; std::cout << "original profile: " << profile(G) << std::endl; @@ -159,7 +159,7 @@ int main(int , char* []) cout << "Sloan ordering starting at: " << s << endl; cout << " "; - for (std::vector::const_iterator i = sloan_order.begin(); + for (auto i = sloan_order.begin(); i != sloan_order.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -199,7 +199,7 @@ int main(int , char* []) cout << endl << "Sloan ordering without a start-vertex:" << endl; cout << " "; - for (std::vector::const_iterator i=sloan_order.begin(); + for (auto i=sloan_order.begin(); i != sloan_order.end(); ++i) cout << index_map[*i] << " "; cout << endl; diff --git a/example/strong-components.cpp b/example/strong-components.cpp index 251b7166..f463f6bd 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -32,8 +32,7 @@ main() (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); std::cout << "Total number of components: " << num << std::endl; - std::vector < int >::iterator i; - for (i = c.begin(); i != c.end(); ++i) + for (auto i = c.begin(); i != c.end(); ++i) std::cout << "Vertex " << i - c.begin() << " is in component " << *i << std::endl; return EXIT_SUCCESS; diff --git a/example/subgraph_properties.cpp b/example/subgraph_properties.cpp index 613d53a3..2f222613 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -49,7 +49,7 @@ int main(int,char*[]) Graph G0(N); enum { A, B, C, D, E, F}; // for conveniently refering to vertices in G0 - property_map::type name = get(vertex_name_t(), G0); + auto name = get(vertex_name_t(), G0); name[A] = "A"; name[B] = "B"; name[C] = "C"; @@ -64,7 +64,7 @@ int main(int,char*[]) add_vertex(E, G1); // global vertex E becomes local B1 for G1 add_vertex(F, G1); // global vertex F becomes local C1 for G1 - property_map::type name1 = get(vertex_name_t(), G1); + auto name1 = get(vertex_name_t(), G1); name1[A1] = "A1"; std::cout << std::endl << "After initializing properties for G1:" << std::endl; @@ -90,7 +90,7 @@ int main(int,char*[]) add_vertex(A, G2); // global vertex A becomes local A2 for G2 add_vertex(C, G2); // global vertex C becomes local B2 for G2 - property_map::type name2 = get(vertex_name_t(), G2); + auto name2 = get(vertex_name_t(), G2); name2[A2] = "A2"; std::cout << std::endl << std::endl << "After initializing properties for G2:" << std::endl; diff --git a/example/successive_shortest_path_nonnegative_weights_example.cpp b/example/successive_shortest_path_nonnegative_weights_example.cpp index 0edc3710..22442ae8 100644 --- a/example/successive_shortest_path_nonnegative_weights_example.cpp +++ b/example/successive_shortest_path_nonnegative_weights_example.cpp @@ -20,7 +20,7 @@ int main() { boost::successive_shortest_path_nonnegative_weights(g, s, t); - int cost = boost::find_flow_cost(g); + auto cost = boost::find_flow_cost(g); assert(cost == 29); return 0; diff --git a/example/tiernan_print_cycles.cpp b/example/tiernan_print_cycles.cpp index c4375615..75d804c8 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -31,8 +31,7 @@ struct cycle_printer { // Get the property map containing the vertex indices // so we can print them. - typedef typename property_map::const_type IndexMap; - IndexMap indices = get(vertex_index, g); + auto indices = get(vertex_index, g); // Iterate over path printing each vertex that forms the cycle. typename Path::const_iterator i, end = p.end(); diff --git a/example/topo-sort-with-leda.cpp b/example/topo-sort-with-leda.cpp index cd24b76e..18a3b4ac 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -46,7 +46,7 @@ main() std::reverse(topo_order.begin(), topo_order.end()); int n = 1; - for (std::vector < vertex_t >::iterator i = topo_order.begin(); + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << n << ": " << leda_g[*i] << std::endl; diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index 9b0ea8e5..cd343dfd 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -42,7 +42,7 @@ main() topological_sort(sgb_g, std::back_inserter(topo_order), vertex_index_map(get(vertex_index, sgb_g))); int n = 1; - for (std::vector < vertex_t >::reverse_iterator i = topo_order.rbegin(); + for (auto i = topo_order.rbegin(); i != topo_order.rend(); ++i, ++n) std::cout << n << ": " << tasks[get(vertex_index, sgb_g)[*i]] << std::endl; diff --git a/example/topo-sort1.cpp b/example/topo-sort1.cpp index 90c98a2d..a05ebca0 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -42,7 +42,7 @@ main() vertex_index_map(identity_property_map())); int n = 1; - for (std::deque < int >::iterator i = topo_order.begin(); + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << tasks[*i] << std::endl; diff --git a/example/topo-sort2.cpp b/example/topo-sort2.cpp index 4663181e..4af97375 100644 --- a/example/topo-sort2.cpp +++ b/example/topo-sort2.cpp @@ -42,7 +42,7 @@ main() vertex_index_map(identity_property_map())); int n = 1; - for (std::deque < int >::iterator i = topo_order.begin(); + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << tasks[*i] << std::endl; diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index 124db6a2..a0a6afb7 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -57,14 +57,14 @@ main(int , char* []) Graph G(edges, edges + 6, 6); #endif - boost::property_map::type id = get(vertex_index, G); + auto id = get(vertex_index, G); typedef std::vector< Vertex > container; container c; topological_sort(G, std::back_inserter(c)); std::cout << "A topological ordering: "; - for (container::reverse_iterator ii = c.rbegin(); + for (auto ii = c.rbegin(); ii != c.rend(); ++ii) std::cout << id[*ii] << " "; std::cout << std::endl; diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 7378dd19..fcd9dedf 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -20,8 +20,7 @@ main() enum { a, b, c, d, e, f, g, N }; graph_t G(N); - property_map < graph_t, vertex_name_t >::type - name_map = get(vertex_name, G); + auto name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index 2fa85179..166c8518 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -84,9 +84,8 @@ int main(int argc, char **argv) tree_collector, inL ); - - std::vector< std::vector >::iterator it; - for(it = coll.begin(); it != coll.end(); ++it) { + + for(const auto& vec : coll) { // Here you can play with the trees that the algorithm has found. } diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 49d31202..2d4ee51d 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -15,13 +15,12 @@ undirected_graph_demo1() { const int V = 3; UndirectedGraph undigraph(V); - typename graph_traits < UndirectedGraph >::vertex_descriptor zero, one, two; typename graph_traits < UndirectedGraph >::out_edge_iterator out, out_end; typename graph_traits < UndirectedGraph >::in_edge_iterator in, in_end; - zero = vertex(0, undigraph); - one = vertex(1, undigraph); - two = vertex(2, undigraph); + auto zero = vertex(0, undigraph); + auto one = vertex(1, undigraph); + auto two = vertex(2, undigraph); add_edge(zero, one, undigraph); add_edge(zero, two, undigraph); add_edge(one, two, undigraph); @@ -40,15 +39,13 @@ directed_graph_demo() { const int V = 2; DirectedGraph digraph(V); - typename graph_traits < DirectedGraph >::vertex_descriptor u, v; typedef typename DirectedGraph::edge_property_type Weight; - typename property_map < DirectedGraph, edge_weight_t >::type - weight = get(edge_weight, digraph); + auto weight = get(edge_weight, digraph); typename graph_traits < DirectedGraph >::edge_descriptor e1, e2; bool found; - u = vertex(0, digraph); - v = vertex(1, digraph); + auto u = vertex(0, digraph); + auto v = vertex(1, digraph); add_edge(u, v, Weight(1.2), digraph); add_edge(v, u, Weight(2.4), digraph); boost::tie(e1, found) = edge(u, v, digraph); @@ -70,15 +67,14 @@ undirected_graph_demo2() { const int V = 2; UndirectedGraph undigraph(V); - typename graph_traits < UndirectedGraph >::vertex_descriptor u, v; typedef typename UndirectedGraph::edge_property_type Weight; typename property_map < UndirectedGraph, edge_weight_t >::type weight = get(edge_weight, undigraph); typename graph_traits < UndirectedGraph >::edge_descriptor e1, e2; bool found; - u = vertex(0, undigraph); - v = vertex(1, undigraph); + auto u = vertex(0, undigraph); + auto v = vertex(1, undigraph); add_edge(u, v, Weight(3.1), undigraph); boost::tie(e1, found) = edge(u, v, undigraph); boost::tie(e2, found) = edge(v, u, undigraph); @@ -94,8 +90,7 @@ undirected_graph_demo2() std::cout << "the edges incident to v: "; typename boost::graph_traits::out_edge_iterator e, e_end; - typename boost::graph_traits::vertex_descriptor - s = vertex(0, undigraph); + auto s = vertex(0, undigraph); for (boost::tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e) std::cout << "(" << source(*e, undigraph) << "," << target(*e, undigraph) << ")" << std::endl; diff --git a/example/undirected_graph.cpp b/example/undirected_graph.cpp index d926c7b5..116d9552 100644 --- a/example/undirected_graph.cpp +++ b/example/undirected_graph.cpp @@ -18,9 +18,9 @@ int main(int,char*[]) Graph g; // Add vertices - boost::graph_traits::vertex_descriptor v0 = g.add_vertex(); - boost::graph_traits::vertex_descriptor v1 = g.add_vertex(); - boost::graph_traits::vertex_descriptor v2 = g.add_vertex(); + auto v0 = g.add_vertex(); + auto v1 = g.add_vertex(); + auto v2 = g.add_vertex(); // Add edges g.add_edge(v0, v1); diff --git a/example/vertex-name-property.cpp b/example/vertex-name-property.cpp index c1216f04..1e2d242f 100644 --- a/example/vertex-name-property.cpp +++ b/example/vertex-name-property.cpp @@ -62,8 +62,7 @@ main() } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); // Create storage for last modified times diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index 8d2053fb..e30e04b2 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -63,11 +63,10 @@ struct print_edge { typedef typename boost::graph_traits::vertex_descriptor Vertex; void operator()(Edge e) const { - typename boost::property_map::type - id = get(vertex_index, G); + auto id = get(vertex_index, G); - Vertex src = source(e, G); - Vertex targ = target(e, G); + auto src = source(e, G); + auto targ = target(e, G); cout << "(" << id[src] << "," << id[targ] << ") "; } diff --git a/example/vf2_sub_graph_iso_multi_example.cpp b/example/vf2_sub_graph_iso_multi_example.cpp index 6f9e34a2..96ea96c4 100644 --- a/example/vf2_sub_graph_iso_multi_example.cpp +++ b/example/vf2_sub_graph_iso_multi_example.cpp @@ -65,14 +65,9 @@ int main() { add_edge(5, 0, edge_property('s'), graph2); // create predicates - typedef property_map::type vertex_name_map_t; - typedef property_map_equivalent vertex_comp_t; - vertex_comp_t vertex_comp = + auto vertex_comp = make_property_map_equivalent(get(vertex_name, graph1), get(vertex_name, graph2)); - - typedef property_map::type edge_name_map_t; - typedef property_map_equivalent edge_comp_t; - edge_comp_t edge_comp = + auto edge_comp = make_property_map_equivalent(get(edge_name, graph1), get(edge_name, graph2)); // Create callback diff --git a/include/boost/graph/bc_clustering.hpp b/include/boost/graph/bc_clustering.hpp index beba4d8e..71deee6f 100644 --- a/include/boost/graph/bc_clustering.hpp +++ b/include/boost/graph/bc_clustering.hpp @@ -112,8 +112,6 @@ betweenness_centrality_clustering(MutableGraph& g, Done done, { typedef typename property_traits::value_type centrality_type; - typedef typename graph_traits::edge_iterator edge_iterator; - typedef typename graph_traits::edge_descriptor edge_descriptor; if (has_no_edges(g)) return; @@ -126,8 +124,8 @@ betweenness_centrality_clustering(MutableGraph& g, Done done, brandes_betweenness_centrality(g, edge_centrality_map(edge_centrality) .vertex_index_map(vertex_index)); - std::pair edges_iters = edges(g); - edge_descriptor e = *max_element(edges_iters.first, edges_iters.second, cmp); + auto edges_iters = edges(g); + auto e = *max_element(edges_iters.first, edges_iters.second, cmp); is_done = done(get(edge_centrality, e), e, g); if (!is_done) remove_edge(e, g); } while (!is_done && !has_no_edges(g)); From 6b7f7b4266242770401eb6740584877982a64212 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 3 May 2016 21:06:55 +0200 Subject: [PATCH 04/28] examples: C++11: Some use of range-based for loop. --- example/cuthill_mckee_ordering.cpp | 19 ++++++++----------- example/edge-connectivity.cpp | 15 +++++++-------- example/king_ordering.cpp | 10 ++++------ example/kruskal-telephone.cpp | 8 ++++---- example/matching_example.cpp | 4 ++-- example/topo-sort1.cpp | 6 ++---- example/topo-sort2.cpp | 6 ++---- 7 files changed, 29 insertions(+), 39 deletions(-) diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index ac26abba..2838f1d7 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -56,8 +56,8 @@ int main(int , char* []) Pair(6,7) }; //g-h Graph G(10); - for (int i = 0; i < 14; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); graph_traits::vertex_iterator ui, ui_end; @@ -78,9 +78,8 @@ int main(int , char* []) get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (auto i = inv_perm.begin(); - i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -96,9 +95,8 @@ int main(int , char* []) get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (auto i=inv_perm.begin(); - i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -115,9 +113,8 @@ int main(int , char* []) cout << "Reverse Cuthill-McKee ordering:" << endl; cout << " "; - for (auto i=inv_perm.begin(); - i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 3267b932..4e0bee42 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -126,12 +126,12 @@ namespace boost } std::vector < bool > in_S_star(num_vertices(g), false); - for (auto si = S_star.begin(); si != S_star.end(); ++si) - in_S_star[*si] = true; + for (const auto& vertex : S_star.begin()) + in_S_star[vertex] = true; degree_size_type c = 0; - for (auto si = S_star.begin(); si != S_star.end(); ++si) { + for (const auto& vertex : S_star.begin()) { typename graph_traits < VertexListGraph >::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; ++c; @@ -159,11 +159,10 @@ main() auto attr_map = get(vertex_attribute, g); std::cout << "The disconnecting set is {"; - for (auto i = - disconnecting_set.begin(); i != disconnecting_set.end(); ++i) + for (const auto& edge : disconnecting_set) std:: - cout << "(" << attr_map[source(*i, g)]["label"] << "," << - attr_map[target(*i, g)]["label"] << ") "; + cout << "(" << attr_map[source(edge, g)]["label"] << "," << + attr_map[target(edge, g)]["label"] << ") "; std::cout << "}." << std::endl; return EXIT_SUCCESS; } diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 73babf4c..daa68e33 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -96,9 +96,8 @@ int main(int , char* []) get(vertex_degree, G), get(vertex_index, G)); cout << "King ordering starting at: " << s << endl; cout << " "; - for (auto i=inv_perm.begin(); - i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -115,9 +114,8 @@ int main(int , char* []) cout << "King ordering:" << endl; cout << " "; - for (auto i=inv_perm.begin(); - i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 085cd36a..a8eb4051 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -36,13 +36,13 @@ main() auto weight = get(edge_weight, g); int total_weight = 0; - for (size_type e = 0; e < mst.size(); ++e) - total_weight += get(weight, mst[e]); + for (const auto& edge : mst) + total_weight += get(weight, edge); std::cout << "total weight: " << total_weight << std::endl; typedef graph_traits < Graph >::vertex_descriptor Vertex; - for (size_type i = 0; i < mst.size(); ++i) { - auto u = source(mst[i], g), v = target(mst[i], g); + for (const auto& edge : mst) { + auto u = source(edge, g), v = target(edge, g); edge_attr_map[edge(u, v, g_dot).first]["color"] = "black"; } std::ofstream out("figs/telephone-mst-kruskal.dot"); diff --git a/example/matching_example.cpp b/example/matching_example.cpp index d38c0006..5bb1b201 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -76,8 +76,8 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for (auto itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) - std::cout << *itr << std::endl; + for (const auto& str : ascii_graph) + std::cout << str << std::endl; std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) << std::endl; diff --git a/example/topo-sort1.cpp b/example/topo-sort1.cpp index a05ebca0..a328060e 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -41,10 +41,8 @@ main() topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); - int n = 1; - for (auto i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) - std::cout << tasks[*i] << std::endl; + for (const auto& vertex : topo_order) + std::cout << tasks[vertex] << std::endl; return EXIT_SUCCESS; } diff --git a/example/topo-sort2.cpp b/example/topo-sort2.cpp index 4af97375..c3d22ff2 100644 --- a/example/topo-sort2.cpp +++ b/example/topo-sort2.cpp @@ -41,10 +41,8 @@ main() topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); - int n = 1; - for (auto i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) - std::cout << tasks[*i] << std::endl; + for (const auto& vertex : topo_order) + std::cout << tasks[vertex] << std::endl; return EXIT_SUCCESS; } From 68375cdbe8002006eeeb36c7e69fbac18f76b7b1 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 4 May 2016 11:01:15 +0200 Subject: [PATCH 05/28] examples: C++11: Use list initialization instead of push_back(). --- example/filtered_vec_as_graph.cpp | 15 +++++++------- example/matching_example.cpp | 17 +++++++-------- example/topo-sort1.cpp | 17 +++++++-------- example/two_graphs_common_spanning_trees.cpp | 31 ++++++++++++++-------------- example/vector_as_graph.cpp | 22 +++++++++----------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/example/filtered_vec_as_graph.cpp b/example/filtered_vec_as_graph.cpp index 2d976a0e..615cd72d 100644 --- a/example/filtered_vec_as_graph.cpp +++ b/example/filtered_vec_as_graph.cpp @@ -38,16 +38,15 @@ int main() { using namespace boost; - enum { A, B, C, D, E, N }; + enum { A, B, C, D, E }; const char* name = "ABCDE"; typedef std::vector < std::list < int > > Graph; - Graph g(N); - g[A].push_back(B); - g[A].push_back(C); - g[C].push_back(D); - g[C].push_back(E); - g[D].push_back(E); - g[E].push_back(C); + Graph g = { + {B, C}, //A + {}, //B + {D, E}, //C + {E}, //D + {C}}; //E constant_target filter(E); filtered_graph fg(g, filter); diff --git a/example/matching_example.cpp b/example/matching_example.cpp index 5bb1b201..87122e5e 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -26,15 +26,14 @@ int main() const int n_vertices = 18; - std::vector ascii_graph; - - ascii_graph.push_back(" 0 1---2 3 "); - ascii_graph.push_back(" \\ / \\ / "); - ascii_graph.push_back(" 4---5 6---7 "); - ascii_graph.push_back(" | | | | "); - ascii_graph.push_back(" 8---9 10---11 "); - ascii_graph.push_back(" / \\ / \\ "); - ascii_graph.push_back(" 12 13 14---15 16 17 "); + std::vector ascii_graph = { + " 0 1---2 3 ", + " \\ / \\ / ", + " 4---5 6---7 ", + " | | | | ", + " 8---9 10---11 ", + " / \\ / \\ ", + " 12 13 14---15 16 17 "}; // It has a perfect matching of size 8. There are two isolated // vertices that we'll use later... diff --git a/example/topo-sort1.cpp b/example/topo-sort1.cpp index a328060e..cb638532 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -25,16 +25,15 @@ main() "pick up kids from soccer", "eat dinner" }; - const int n_tasks = sizeof(tasks) / sizeof(char *); - std::vector < std::list < int > > g(n_tasks); - g[0].push_back(3); - g[1].push_back(3); - g[1].push_back(4); - g[2].push_back(1); - g[3].push_back(5); - g[4].push_back(6); - g[5].push_back(6); + std::vector < std::list < int > > g = { + {3}, + {3, 4}, + {1}, + {5}, + {6}, + {6}, + {}}; std::deque < int >topo_order; diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index 166c8518..9e05fcc2 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -51,22 +51,21 @@ edge_iterator; int main(int argc, char **argv) { Graph iG, vG; - vector< edge_descriptor > iG_o; - vector< edge_descriptor > vG_o; - - iG_o.push_back(boost::add_edge(0, 1, iG).first); - iG_o.push_back(boost::add_edge(0, 2, iG).first); - iG_o.push_back(boost::add_edge(0, 3, iG).first); - iG_o.push_back(boost::add_edge(0, 4, iG).first); - iG_o.push_back(boost::add_edge(1, 2, iG).first); - iG_o.push_back(boost::add_edge(3, 4, iG).first); - - vG_o.push_back(boost::add_edge(1, 2, vG).first); - vG_o.push_back(boost::add_edge(2, 0, vG).first); - vG_o.push_back(boost::add_edge(2, 3, vG).first); - vG_o.push_back(boost::add_edge(4, 3, vG).first); - vG_o.push_back(boost::add_edge(0, 3, vG).first); - vG_o.push_back(boost::add_edge(0, 4, vG).first); + vector< edge_descriptor > iG_o = { + boost::add_edge(0, 1, iG).first, + boost::add_edge(0, 2, iG).first, + boost::add_edge(0, 3, iG).first, + boost::add_edge(0, 4, iG).first, + boost::add_edge(1, 2, iG).first, + boost::add_edge(3, 4, iG).first}; + + vector< edge_descriptor > vG_o= { + boost::add_edge(1, 2, vG).first, + boost::add_edge(2, 0, vG).first, + boost::add_edge(2, 3, vG).first, + boost::add_edge(4, 3, vG).first, + boost::add_edge(0, 3, vG).first, + boost::add_edge(0, 4, vG).first}; vector inL(iG_o.size(), false); diff --git a/example/vector_as_graph.cpp b/example/vector_as_graph.cpp index ccf6abeb..f87d776b 100644 --- a/example/vector_as_graph.cpp +++ b/example/vector_as_graph.cpp @@ -20,20 +20,18 @@ int main() { enum - { r, s, t, u, v, w, x, y, N }; + { r, s, t, u, v, w, x, y }; char name[] = "rstuvwxy"; typedef std::vector < std::list < int > > Graph; - Graph g(N); - g[r].push_back(v); - g[s].push_back(r); - g[s].push_back(r); - g[s].push_back(w); - g[t].push_back(x); - g[u].push_back(t); - g[w].push_back(t); - g[w].push_back(x); - g[x].push_back(y); - g[y].push_back(u); + Graph g = { + {v}, //r + {r, r, w}, //s + {x}, //t + {t}, //u + {}, //v + {t, x}, //w + {y}, //x + {u}}; //y boost::print_graph(g, name); return 0; } From d873a727d4b5dbad236831da5b44f6e61f29de51 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 4 May 2016 11:41:39 +0200 Subject: [PATCH 06/28] examples: C++11: Use emplace_*(). Use emplace_back() and emplace_front() instead of push_back() and push_front(). --- example/accum-compile-times.cpp | 2 +- example/actor_clustering.cpp | 4 ++-- example/astar-cities.cpp | 2 +- example/bfs-example2.cpp | 2 +- example/edge-connectivity.cpp | 4 ++-- example/fibonacci_heap.cpp | 2 +- example/loops_dfs.cpp | 2 +- example/matching_example.cpp | 2 +- example/parallel-compile-time.cpp | 2 +- example/roget_components.cpp | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 02651c15..4ee30870 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -59,7 +59,7 @@ main() std::vector id2vertex; file_dep_graph2 g; for (std::size_t i = 0; i < n_vertices; ++i) - id2vertex.push_back(add_vertex(g)); + id2vertex.emplace_back(add_vertex(g)); std::pair p; while (file_in >> p) add_edge(id2vertex[p.first], id2vertex[p.second], g); diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 45623ca1..93633be1 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -56,9 +56,9 @@ void load_actor_graph(std::istream& in, ActorGraph& g) if (v == actors.end()) { auto new_vertex = add_vertex(Actor(actor_id), g); actors[actor_id] = new_vertex; - actors_in_movie.push_back(new_vertex); + actors_in_movie.emplace_back(new_vertex); } else { - actors_in_movie.push_back(v->second); + actors_in_movie.emplace_back(v->second); } } diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 77f2beb0..fb310087 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -203,7 +203,7 @@ int main(int argc, char **argv) } catch(found_goal fg) { // found a path to the goal list shortest_path; for(auto v = goal;; v = p[v]) { - shortest_path.push_front(v); + shortest_path.emplace_front(v); if(p[v] == v) break; } diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index 2a5f92a8..fbf73612 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -56,7 +56,7 @@ main() graph_t g; std::vector::vertex_descriptor> verts; for (std::size_t i = 0; i < N; ++i) - verts.push_back(add_vertex(g)); + verts.emplace_back(add_vertex(g)); for (std::size_t j = 0; j < n_edges; ++j) add_edge(verts[edge_array[j].first], verts[edge_array[j].second], g); #else diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 4e0bee42..fc0786c6 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -95,7 +95,7 @@ namespace boost } boost::tie(p, delta) = min_degree_vertex(g); - S_star.push_back(p); + S_star.emplace_back(p); alpha_star = delta; S.insert(p); neighbor_S.insert(p); @@ -114,7 +114,7 @@ namespace boost S_star.clear(); for (boost::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) if (color[*vi] != Color::white()) - S_star.push_back(*vi); + S_star.emplace_back(*vi); } S.insert(k); neighbor_S.insert(k); diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index 2f1f1e95..7eefa194 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -48,7 +48,7 @@ main() } for (i = 0; i < N; ++i) { - v.push_back(w[Q.top()]); + v.emplace_back(w[Q.top()]); Q.pop(); } std::sort(w.begin(), w.end()); diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 52d7f78a..de8f701f 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -59,7 +59,7 @@ find_loops(typename graph_traits < Graph >::vertex_descriptor entry, for (typename std::vector < Edge >::size_type i = 0; i < back_edges.size(); ++i) { typename Loops::value_type x; - loops.push_back(x); + loops.emplace_back(x); compute_loop_extent(back_edges[i], g, loops.back()); } } diff --git a/example/matching_example.cpp b/example/matching_example.cpp index 87122e5e..5c6c26bf 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -92,7 +92,7 @@ int main() //now we'll add two edges, and the perfect matching has size 9 ascii_graph.pop_back(); - ascii_graph.push_back(" 12---13 14---15 16---17 "); + ascii_graph.emplace_back(" 12---13 14---15 16---17 "); add_edge(12,13,g); add_edge(16,17,g); diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 271cdec6..970dac1e 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -131,7 +131,7 @@ main() typedef graph_traits::vertex_descriptor vertex_t; std::vector id2vertex; for (std::size_t v = 0; v < n_vertices; ++v) - id2vertex.push_back(add_vertex(g)); + id2vertex.emplace_back(add_vertex(g)); while (input_begin != input_end) { size_type i, j; boost::tie(i, j) = *input_begin++; diff --git a/example/roget_components.cpp b/example/roget_components.cpp index ce775fd1..d22eb6cf 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -72,12 +72,12 @@ int main(int argc, char* argv[]) graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] == *vi) - strong_comp[comp[index_map[*vi]]].push_back(*vi); + strong_comp[comp[index_map[*vi]]].emplace_back(*vi); // Then add the other vertices of the component for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] != *vi) - strong_comp[comp[index_map[*vi]]].push_back(*vi); + strong_comp[comp[index_map[*vi]]].emplace_back(*vi); // We do not print out the "from" and "to" information as Knuth // does because we no longer have easy access to that information From c3e0a3558d9ea99f898d47b2a281be2f905fce6f Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 4 May 2016 12:40:48 +0200 Subject: [PATCH 07/28] examples: C++11: Use using instead of typedef. --- example/accum-compile-times.cpp | 11 ++-- example/actor_clustering.cpp | 12 ++--- example/adj_list_ra_edgelist.cpp | 6 +-- example/adjacency_list.cpp | 4 +- example/adjacency_list_io.cpp | 26 +++++---- example/adjacency_matrix.cpp | 4 +- example/astar-cities.cpp | 16 +++--- example/astar_maze.cpp | 21 ++++---- example/bellman-example.cpp | 6 +-- example/bellman-ford-internet.cpp | 4 +- example/bfs-example.cpp | 15 +++--- example/bfs-example2.cpp | 19 ++++--- example/bfs-name-printer.cpp | 4 +- example/bfs.cpp | 10 ++-- example/bfs_neighbor.cpp | 10 ++-- example/biconnected_components.cpp | 8 +-- example/bipartite_example.cpp | 14 ++--- example/boost_web_graph.cpp | 18 +++---- example/boykov_kolmogorov-eg.cpp | 6 +-- example/bron_kerbosch_clique_number.cpp | 6 +-- example/bron_kerbosch_print_cliques.cpp | 8 +-- example/bucket_sorter.cpp | 6 +-- example/canonical_ordering.cpp | 10 ++-- example/city_visitor.cpp | 10 ++-- example/closeness_centrality.cpp | 22 ++++---- example/clustering_coefficient.cpp | 14 ++--- example/components_on_edgelist.cpp | 4 +- example/connected-components.cpp | 2 +- example/connected_components.cpp | 2 +- example/container_gen.cpp | 10 ++-- example/copy-example.cpp | 6 +-- example/csr-example.cpp | 4 +- example/cuthill_mckee_ordering.cpp | 10 ++-- example/cycle-file-dep.cpp | 10 ++-- example/cycle-file-dep2.cpp | 10 ++-- example/cycle_ratio_example.cpp | 6 +-- example/dag_shortest_paths.cpp | 4 +- example/dave.cpp | 20 +++---- example/default-constructor.cpp | 6 +-- example/default-constructor2.cpp | 8 +-- example/degree_centrality.cpp | 14 ++--- example/dfs-example.cpp | 13 +++-- example/dfs.cpp | 6 +-- example/dfs_parenthesis.cpp | 8 +-- example/dijkstra-example-listS.cpp | 10 ++-- example/dijkstra-example.cpp | 8 +-- example/dijkstra-no-color-map-example.cpp | 8 +-- example/directed_graph.cpp | 2 +- example/eccentricity.cpp | 22 ++++---- example/edge-connectivity.cpp | 22 ++++---- example/edge-function.cpp | 6 +-- example/edge-iter-constructor.cpp | 6 +-- example/edge_basics.cpp | 8 +-- example/edge_coloring.cpp | 4 +- example/edge_connectivity.cpp | 6 +-- example/edge_iterator_constructor.cpp | 14 ++--- example/edge_property.cpp | 14 ++--- example/edmonds-karp-eg.cpp | 6 +-- example/exterior_properties.cpp | 14 ++--- example/exterior_property_map.cpp | 4 +- example/fibonacci_heap.cpp | 2 +- example/file_dependencies.cpp | 8 +-- example/filtered-copy-example.cpp | 6 +-- example/filtered_graph.cpp | 6 +-- example/filtered_graph_edge_range.cpp | 3 +- example/filtered_vec_as_graph.cpp | 2 +- example/fr_layout.cpp | 21 ++++---- example/gerdemann.cpp | 12 ++--- example/girth.cpp | 14 ++--- example/graph-assoc-types.cpp | 14 ++--- example/graph-property-iter-eg.cpp | 4 +- example/graph-thingie.cpp | 18 +++---- example/graph.cpp | 10 ++-- example/graph_as_tree.cpp | 12 ++--- example/graph_property.cpp | 6 +-- example/graphviz.cpp | 10 ++-- example/grid_graph_example.cpp | 4 +- example/grid_graph_properties.cpp | 4 +- example/hawick_circuits.cpp | 4 +- example/helper.hpp | 18 +++---- example/implicit_graph.cpp | 79 +++++++++++++--------------- example/in_edges.cpp | 2 +- example/inclusive_mean_geodesic.cpp | 26 ++++----- example/incremental-components-eg.cpp | 14 ++--- example/incremental_components.cpp | 12 ++--- example/influence_prestige.cpp | 14 ++--- example/interior_pmap_bundled.cpp | 4 +- example/interior_property_map.cpp | 12 ++--- example/isomorphism.cpp | 4 +- example/johnson-eg.cpp | 6 +-- example/kevin-bacon.cpp | 8 +-- example/kevin-bacon2.cpp | 8 +-- example/king_ordering.cpp | 10 ++-- example/knights_tour.cpp | 61 ++++++++------------- example/kruskal-example.cpp | 8 +-- example/kruskal-telephone.cpp | 8 +-- example/kuratowski_subgraph.cpp | 8 ++- example/labeled_graph.cpp | 14 ++--- example/last-mod-time.cpp | 12 ++--- example/leda-concept-check.cpp | 2 +- example/leda-graph-eg.cpp | 4 +- example/loops_dfs.cpp | 16 +++--- example/make_biconnected_planar.cpp | 15 +++--- example/make_connected.cpp | 5 +- example/make_maximal_planar.cpp | 7 ++- example/matching_example.cpp | 2 +- example/max_flow.cpp | 6 +-- example/mcgregor_subgraphs_example.cpp | 14 ++--- example/mean_geodesic.cpp | 22 ++++---- example/miles_span.cpp | 2 +- example/min_max_paths.cpp | 8 +-- example/minimum_degree_ordering.cpp | 6 +-- example/modify_graph.cpp | 6 +-- example/neighbor_bfs.cpp | 17 +++--- example/ordered_out_edges.cpp | 16 +++--- example/ospf-example.cpp | 13 +++-- example/parallel-compile-time.cpp | 30 +++++------ example/planar_face_traversal.cpp | 7 ++- example/prim-example.cpp | 6 +-- example/prim-telephone.cpp | 6 +-- example/print-adjacent-vertices.cpp | 6 +-- example/print-edges.cpp | 6 +-- example/print-in-edges.cpp | 6 +-- example/print-out-edges.cpp | 8 +-- example/property-map-traits-eg.cpp | 4 +- example/property_iterator.cpp | 24 ++++----- example/push-relabel-eg.cpp | 6 +-- example/put-get-helper-eg.cpp | 16 +++--- example/quick-tour.cpp | 6 +-- example/quick_tour.cpp | 12 ++--- example/r_c_shortest_paths_example.cpp | 5 +- example/reachable-loop-head.cpp | 2 +- example/reachable-loop-tail.cpp | 6 +-- example/read_graphviz.cpp | 12 ++--- example/read_write_dimacs-eg.cpp | 20 +++---- example/remove_edge_if_bidir.cpp | 6 +-- example/remove_edge_if_dir.cpp | 4 +- example/remove_edge_if_undir.cpp | 6 +-- example/reverse_graph.cpp | 2 +- example/roget_components.cpp | 2 +- example/scaled_closeness_centrality.cpp | 26 ++++----- example/scc.cpp | 2 +- example/simple_planarity_test.cpp | 4 +- example/sloan_ordering.cpp | 10 ++-- example/stoer_wagner.cpp | 8 +-- example/straight_line_drawing.cpp | 19 +++---- example/strong-components.cpp | 2 +- example/strong_components.cpp | 2 +- example/subgraph.cpp | 4 +- example/subgraph_properties.cpp | 10 ++-- example/tiernan_girth_circumference.cpp | 6 +-- example/tiernan_print_cycles.cpp | 6 +-- example/topo-sort-file-dep.cpp | 10 ++-- example/topo-sort-file-dep2.cpp | 10 ++-- example/topo-sort-with-leda.cpp | 4 +- example/topo-sort-with-sgb.cpp | 2 +- example/topo_sort.cpp | 10 ++-- example/transitive_closure.cpp | 8 +-- example/transpose-example.cpp | 6 +-- example/two_graphs_common_spanning_trees.cpp | 26 ++++----- example/undirected_adjacency_list.cpp | 14 ++--- example/undirected_dfs.cpp | 6 +-- example/undirected_graph.cpp | 2 +- example/vector_as_graph.cpp | 2 +- example/vertex-name-property.cpp | 10 ++-- example/vertex_basics.cpp | 12 ++--- example/vf2_sub_graph_iso_example.cpp | 2 +- example/vf2_sub_graph_iso_multi_example.cpp | 6 +-- example/visitor.cpp | 8 +-- example/write_graphviz.cpp | 6 +-- 170 files changed, 818 insertions(+), 869 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 4ee30870..aef1085e 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -32,7 +32,7 @@ namespace boost using namespace boost; -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list +using file_dep_graph2 = adjacency_list< listS, // Store out-edges of each vertex in a std::list listS, // Store vertex set in a std::list directedS, // The file dependency graph is directed // vertex properties @@ -41,17 +41,16 @@ typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list property < vertex_distance_t, float, property < vertex_color_t, default_color_type > > > >, // an edge property - property < edge_weight_t, float > > - file_dep_graph2; + property < edge_weight_t, float > >; -typedef graph_traits::vertex_descriptor vertex_t; -typedef graph_traits::edge_descriptor edge_t; +using vertex_t = graph_traits::vertex_descriptor; +using edge_t = graph_traits::edge_descriptor; int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits::vertices_size_type size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 93633be1..11fa3ce0 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -34,10 +34,10 @@ struct Actor int id; }; -typedef adjacency_list > ActorGraph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using ActorGraph = adjacency_list >; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; void load_actor_graph(std::istream& in, ActorGraph& g) { @@ -48,7 +48,7 @@ void load_actor_graph(std::istream& in, ActorGraph& g) std::vector actors_in_movie; // Map from the actor numbers on this line to the actor vertices - typedef tokenizer > Tok; + using Tok = tokenizer >; Tok tok(line, char_separator(" ")); for (const auto& id : tok) { auto actor_id = lexical_cast(id); @@ -92,7 +92,7 @@ write_pajek_graph(std::ostream& out, const Graph& g, class actor_clustering_threshold : public bc_clustering_threshold { - typedef bc_clustering_threshold inherited; + using inherited = bc_clustering_threshold; public: actor_clustering_threshold(double threshold, const ActorGraph& g, diff --git a/example/adj_list_ra_edgelist.cpp b/example/adj_list_ra_edgelist.cpp index d92ecd66..13b5e124 100644 --- a/example/adj_list_ra_edgelist.cpp +++ b/example/adj_list_ra_edgelist.cpp @@ -15,11 +15,11 @@ int main() { using namespace boost; - typedef adjacency_list, no_property, vecS> Graph; + using Graph = adjacency_list, no_property, vecS>; const std::size_t n = 3; - typedef std::pair E; + using E = std::pair; E edge_array[] = { E(0,1), E(0,2), E(0,1) }; const std::size_t m = sizeof(edge_array) / sizeof(E); Graph g(edge_array, edge_array + m, n); diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index 282c7cf5..46dac9e3 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -53,8 +53,8 @@ int main(int , char* []) using namespace boost; using namespace std; - typedef adjacency_list Graph; + using Graph = adjacency_list; const int V = 5; Graph g(V); diff --git a/example/adjacency_list_io.cpp b/example/adjacency_list_io.cpp index ab626f89..5dad6b83 100644 --- a/example/adjacency_list_io.cpp +++ b/example/adjacency_list_io.cpp @@ -28,29 +28,27 @@ std::istream& operator >> ( std::istream& in, MyStruct& s ) } //======== vertex properties -struct n1_t { enum { num = 23063}; typedef vertex_property_tag kind; }; -struct n2_t { enum { num = 23062}; typedef vertex_property_tag kind; }; -struct n3_t { enum { num = 23061}; typedef vertex_property_tag kind; }; -typedef property< n1_t, int, +struct n1_t { enum { num = 23063}; using kind = vertex_property_tag; }; +struct n2_t { enum { num = 23062}; using kind = vertex_property_tag; }; +struct n3_t { enum { num = 23061}; using kind = vertex_property_tag; }; +using VertexProperty = property< n1_t, int, property< n2_t, double, - property< n3_t, MyStruct > > > VertexProperty; + property< n3_t, MyStruct > > >; //====== edge properties -struct e1_t { enum { num = 23064}; typedef edge_property_tag kind; }; -typedef property EdgeProperty; +struct e1_t { enum { num = 23064}; using kind = edge_property_tag; }; +using EdgeProperty = property; //===== graph types -typedef - adjacency_list - Graph1; +using Graph1 = + adjacency_list; -typedef - adjacency_list - Graph2; +using Graph2 = + adjacency_list; @@ -84,7 +82,7 @@ main() // read Graph2, incomplete data in a different order. Write it diffently. Graph2 g31; std::ifstream readFile31("data3.txt"); - typedef property< n3_t, MyStruct, property< n1_t, int > > readNodeProp; + using readNodeProp = property< n3_t, MyStruct, property< n1_t, int > >; readFile31 >> read( g31, readNodeProp() , EdgeProperty() ); std::cout << "graph g31 from file data3.txt:\n" << write( g31, property(), EdgeProperty() ) diff --git a/example/adjacency_matrix.cpp b/example/adjacency_matrix.cpp index accbfca1..edd3d304 100644 --- a/example/adjacency_matrix.cpp +++ b/example/adjacency_matrix.cpp @@ -20,7 +20,7 @@ int main() // A directed graph - typedef adjacency_matrix Graph; + using Graph = adjacency_matrix; Graph g(N); add_edge(B, C, g); add_edge(B, F, g); @@ -44,7 +44,7 @@ int main() // An undirected graph - typedef adjacency_matrix UGraph; + using UGraph = adjacency_matrix; UGraph ug(N); add_edge(B, C, ug); add_edge(B, F, ug); diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index fb310087..dc628f58 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -32,7 +32,7 @@ struct location { float y, x; // lat, long }; -typedef float cost; +using cost = float; template class city_writer { @@ -76,7 +76,7 @@ template class distance_heuristic : public astar_heuristic { public: - typedef typename graph_traits::vertex_descriptor Vertex; + using Vertex = typename graph_traits::vertex_descriptor; distance_heuristic(LocMap l, Vertex goal) : m_location(l), m_goal(goal) {} CostType operator()(Vertex u) @@ -113,12 +113,12 @@ int main(int argc, char **argv) { // specify some types - typedef adjacency_list > mygraph_t; - typedef property_map::type WeightMap; - typedef mygraph_t::vertex_descriptor vertex; - typedef mygraph_t::edge_descriptor edge_descriptor; - typedef std::pair edge; + using mygraph_t = adjacency_list >; + using WeightMap = property_map::type; + using vertex = mygraph_t::vertex_descriptor; + using edge_descriptor = mygraph_t::edge_descriptor; + using edge = std::pair; // specify data enum nodes { diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 973ed380..e1c5e14b 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -38,12 +38,12 @@ boost::mt19937 random_generator; // Distance traveled in the maze -typedef double distance; +using distance = double; #define GRID_RANK 2 -typedef boost::grid_graph grid; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::vertices_size_type vertices_size_type; +using grid = boost::grid_graph; +using vertex_descriptor = boost::graph_traits::vertex_descriptor; +using vertices_size_type = boost::graph_traits::vertices_size_type; // A hash function for vertices. struct vertex_hash:std::unary_function { @@ -55,9 +55,8 @@ struct vertex_hash:std::unary_function { } }; -typedef boost::unordered_set vertex_set; -typedef boost::vertex_subset_complement_filter::type - filtered_grid; +using vertex_set = boost::unordered_set; +using filtered_grid = boost::vertex_subset_complement_filter::type; // A searchable maze // @@ -166,15 +165,15 @@ struct astar_goal_visitor:public boost::default_astar_visitor { bool maze::solve() { boost::static_property_map weight(1); // The predecessor map is a vertex-to-vertex mapping. - typedef boost::unordered_map pred_map; + vertex_hash>; pred_map predecessor; boost::associative_property_map pred_pmap(predecessor); // The distance map is a vertex-to-distance mapping. - typedef boost::unordered_map dist_map; + vertex_hash>; dist_map distance; boost::associative_property_map dist_pmap(distance); diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index 34e13c27..a62c1386 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -53,14 +53,14 @@ main() { enum { u, v, x, y, z, N }; char name[] = { 'u', 'v', 'x', 'y', 'z' }; - typedef std::pair < int, int >E; + using E = std::pair < int, int >; const int n_edges = 10; E edge_array[] = { E(u, y), E(u, x), E(u, v), E(v, u), E(x, y), E(x, v), E(y, v), E(y, z), E(z, u), E(z,x) }; int weight[n_edges] = { -4, 8, 5, -2, 9, -3, 7, 2, 6, 7 }; - typedef adjacency_list < vecS, vecS, directedS, - no_property, EdgeProperties> Graph; + using Graph = adjacency_list < vecS, vecS, directedS, + no_property, EdgeProperties>; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor Graph g(N); diff --git a/example/bellman-ford-internet.cpp b/example/bellman-ford-internet.cpp index 24bbfef4..1f25316d 100644 --- a/example/bellman-ford-internet.cpp +++ b/example/bellman-ford-internet.cpp @@ -17,7 +17,7 @@ main() enum { A, B, C, D, E, F, G, H, n_vertices }; const int n_edges = 11; - typedef std::pair < int, int >Edge; + using Edge = std::pair < int, int >; // The list of connections between routers stored in an array. Edge edges[] = { @@ -27,7 +27,7 @@ main() }; // Specify the graph type and declare a graph object - typedef edge_list < Edge*, Edge, std::ptrdiff_t, std::random_access_iterator_tag> Graph; + using Graph = edge_list < Edge*, Edge, std::ptrdiff_t, std::random_access_iterator_tag>; Graph g(edges, edges + n_edges); // The transmission delay values for each edge. diff --git a/example/bfs-example.cpp b/example/bfs-example.cpp index 0436204c..56e73240 100644 --- a/example/bfs-example.cpp +++ b/example/bfs-example.cpp @@ -14,7 +14,7 @@ using namespace boost; template < typename TimeMap > class bfs_time_visitor:public default_bfs_visitor { - typedef typename property_traits < TimeMap >::value_type T; + using T = typename property_traits < TimeMap >::value_type; public: bfs_time_visitor(TimeMap tmap, T & t):m_timemap(tmap), m_time(t) { } template < typename Vertex, typename Graph > @@ -32,12 +32,12 @@ main() { using namespace boost; // Select the graph type we wish to use - typedef adjacency_list < vecS, vecS, undirectedS > graph_t; + using graph_t = adjacency_list < vecS, vecS, undirectedS >; // Set up the vertex IDs and names enum { r, s, t, u, v, w, x, y, N }; const char *name = "rstuvwxy"; // Specify the edges in the graph - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; @@ -49,19 +49,18 @@ main() for (std::size_t j = 0; j < n_edges; ++j) add_edge(edge_array[j].first, edge_array[j].second, g); #else - typedef graph_traits::vertices_size_type v_size_t; + using v_size_t = graph_traits::vertices_size_type; graph_t g(edge_array, edge_array + n_edges, v_size_t(N)); #endif // Typedefs - typedef graph_traits < graph_t >::vertices_size_type Size; + using Size = graph_traits < graph_t >::vertices_size_type; // a vector to hold the discover time property for each vertex std::vector < Size > dtime(num_vertices(g)); - typedef + using dtime_pm_type = iterator_property_map::iterator, - property_map::const_type> - dtime_pm_type; + property_map::const_type>; dtime_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); Size time = 0; diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index fbf73612..d47d0292 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -15,7 +15,7 @@ using namespace boost; template < typename TimeMap > class bfs_time_visitor:public default_bfs_visitor { - typedef typename property_traits < TimeMap >::value_type T; + using T = typename property_traits < TimeMap >::value_type; public: bfs_time_visitor(TimeMap tmap, T & t):m_timemap(tmap), m_time(t) { } template < typename Vertex, typename Graph > @@ -39,13 +39,13 @@ main() { using namespace boost; // Select the graph type we wish to use - typedef adjacency_list < listS, listS, undirectedS, - VertexProps> graph_t; + using graph_t = adjacency_list < listS, listS, undirectedS, + VertexProps>; // Set up the vertex IDs and names enum { r, s, t, u, v, w, x, y, N }; const char *name = "rstuvwxy"; // Specify the edges in the graph - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; @@ -60,15 +60,15 @@ main() for (std::size_t j = 0; j < n_edges; ++j) add_edge(verts[edge_array[j].first], verts[edge_array[j].second], g); #else - typedef graph_traits::vertices_size_type v_size_t; + using v_size_t = graph_traits::vertices_size_type; graph_t g(edge_array, edge_array + n_edges, v_size_t(N)); #endif // Typedefs - typedef graph_traits::vertices_size_type Size; + using Size = graph_traits::vertices_size_type; Size time = 0; - typedef property_map::type dtime_map_t; + using dtime_map_t = property_map::type; auto dtime_map = get(&VertexProps::discover_time, g); bfs_time_visitor < dtime_map_t > vis(dtime_map, time); breadth_first_search(g, vertex(s, g), color_map(get(&VertexProps::color, g)). @@ -76,10 +76,9 @@ main() // a vector to hold the discover time property for each vertex std::vector < Size > dtime(num_vertices(g)); - typedef + using dtime_pm_type = iterator_property_map::iterator, - property_map::type> - dtime_pm_type; + property_map::type>; graph_traits::vertex_iterator vi, vi_end; std::size_t c = 0; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) { diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index e05cc9e9..1ba1ee5f 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -75,7 +75,7 @@ struct EP { int main() { - typedef adjacency_list < listS, vecS, directedS, VP, EP> graph_t; + using graph_t = adjacency_list < listS, vecS, directedS, VP, EP>; graph_t g; auto name_map = get(&VP::name, g); @@ -83,7 +83,7 @@ main() build_router_network(g, name_map, delay_map); - typedef property_map::type VertexNameMap; + using VertexNameMap = property_map::type; auto a = *vertices(g).first; bfs_name_printer vis(name_map); std::cout << "BFS vertex discover order: "; diff --git a/example/bfs.cpp b/example/bfs.cpp index 5df01d0f..39cc7c5a 100644 --- a/example/bfs.cpp +++ b/example/bfs.cpp @@ -71,7 +71,7 @@ template struct graph_copier : public boost::base_visitor > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) { } @@ -91,13 +91,13 @@ copy_graph(NewGraph& g, Tag) { int main(int , char* []) { - typedef boost::adjacency_list< + using Graph = boost::adjacency_list< boost::mapS, boost::vecS, boost::bidirectionalS, boost::property > > > - > Graph; + >; Graph G(5); boost::add_edge(0, 2, G); @@ -112,7 +112,7 @@ int main(int , char* []) boost::add_edge(4, 0, G); boost::add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; Graph G_copy(5); // Array to store predecessor (parent) of each vertex. This will be @@ -120,7 +120,7 @@ int main(int , char* []) std::vector p(boost::num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector::value_type* Piter; + using Piter = std::vector::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index f6238310..148f90cc 100644 --- a/example/bfs_neighbor.cpp +++ b/example/bfs_neighbor.cpp @@ -66,7 +66,7 @@ template struct graph_copier : public boost::base_visitor > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) { } @@ -86,13 +86,13 @@ copy_graph(NewGraph& g, Tag) { int main(int , char* []) { - typedef boost::adjacency_list< + using Graph = boost::adjacency_list< boost::mapS, boost::vecS, boost::bidirectionalS, boost::property > > > - > Graph; + >; Graph G(5); boost::add_edge(0, 2, G); @@ -107,14 +107,14 @@ int main(int , char* []) boost::add_edge(4, 0, G); boost::add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; // Array to store predecessor (parent) of each vertex. This will be // used as a Decorator (actually, its iterator will be). std::vector p(boost::num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector::value_type* Piter; + using Piter = std::vector::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index dc09ca49..8a9ac16f 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -19,7 +19,7 @@ namespace boost { enum { num = 555 }; - typedef edge_property_tag kind; + using kind = edge_property_tag; } edge_component; } @@ -28,9 +28,9 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, undirectedS, - no_property, property < edge_component_t, std::size_t > >graph_t; - typedef graph_traits < graph_t >::vertex_descriptor vertex_t; + using graph_t = adjacency_list < vecS, vecS, undirectedS, + no_property, property < edge_component_t, std::size_t > >; + using vertex_t = graph_traits < graph_t >::vertex_descriptor; graph_t g(9); add_edge(0, 5, g); add_edge(0, 1, g); diff --git a/example/bipartite_example.cpp b/example/bipartite_example.cpp index c8e62ad2..507202db 100644 --- a/example/bipartite_example.cpp +++ b/example/bipartite_example.cpp @@ -21,7 +21,7 @@ using namespace boost; template void print_bipartite (const Graph& g) { - typedef graph_traits traits; + using traits = graph_traits ; typename traits::vertex_iterator vertex_iter, vertex_end; /// Most simple interface just tests for bipartiteness. @@ -30,9 +30,9 @@ void print_bipartite (const Graph& g) if (bipartite) { - typedef std::vector partition_t; - typedef typename property_map ::type index_map_t; - typedef iterator_property_map partition_map_t; + using partition_t = std::vector ; + using index_map_t = typename property_map ::type; + using partition_map_t = iterator_property_map ; partition_t partition (num_vertices (g)); partition_map_t partition_map (partition.begin (), get (vertex_index, g)); @@ -49,7 +49,7 @@ void print_bipartite (const Graph& g) } else { - typedef std::vector vertex_vector_t; + using vertex_vector_t = std::vector ; vertex_vector_t odd_cycle; /// A third interface yields an odd-cycle if the graph is not bipartite. @@ -67,8 +67,8 @@ void print_bipartite (const Graph& g) int main (int argc, char **argv) { - typedef adjacency_list vector_graph_t; - typedef std::pair E; + using vector_graph_t = adjacency_list ; + using E = std::pair ; /** * Create the graph drawn below. diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index c0377d2e..6cf3eccd 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -49,7 +49,7 @@ class print_tree_visitor : public boost::dfs_visitor<> discover_vertex(typename boost::graph_traits::vertex_descriptor v, Graph&) { - typedef typename boost::property_traits::value_type Dist; + using Dist = typename boost::property_traits::value_type; // indentation based on depth for (Dist i = 0; i < distance[v]; ++i) std::cout << " "; @@ -82,17 +82,17 @@ main() //=========================================================================== // Declare the graph type and object, and some property maps. - typedef adjacency_list >, property > - > Graph; + >; - typedef graph_traits Traits; - typedef Traits::vertex_descriptor Vertex; - typedef Traits::edge_descriptor Edge; + using Traits = graph_traits; + using Vertex = Traits::vertex_descriptor; + using Edge = Traits::edge_descriptor; - typedef std::map NameVertexMap; + using NameVertexMap = std::map; NameVertexMap name2vertex; Graph g; @@ -143,8 +143,8 @@ main() //=========================================================================== // Calculate the diameter of the graph. - typedef Traits::vertices_size_type size_type; - typedef std::vector IntVector; + using size_type = Traits::vertices_size_type; + using IntVector = std::vector; // Create N x N matrix for storing the shortest distances // between each vertex. Initialize all distances to zero. std::vector d_matrix(num_vertices(g), diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index 482805c0..64cf1b90 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -70,8 +70,8 @@ int main() { using namespace boost; - typedef adjacency_list_traits < vecS, vecS, directedS > Traits; - typedef adjacency_list < vecS, vecS, directedS, + using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Graph = adjacency_list < vecS, vecS, directedS, property < vertex_name_t, std::string, property < vertex_index_t, long, property < vertex_color_t, boost::default_color_type, @@ -80,7 +80,7 @@ int main() property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; + property < edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; auto capacity = get(edge_capacity, g); diff --git a/example/bron_kerbosch_clique_number.cpp b/example/bron_kerbosch_clique_number.cpp index 12ac3c90..232d84e8 100644 --- a/example/bron_kerbosch_clique_number.cpp +++ b/example/bron_kerbosch_clique_number.cpp @@ -16,9 +16,9 @@ using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. -typedef undirected_graph<> Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph<>; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; int main(int argc, char *argv[]) diff --git a/example/bron_kerbosch_print_cliques.cpp b/example/bron_kerbosch_print_cliques.cpp index 93030edd..100d9fb8 100644 --- a/example/bron_kerbosch_print_cliques.cpp +++ b/example/bron_kerbosch_print_cliques.cpp @@ -44,13 +44,13 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; int main(int argc, char *argv[]) diff --git a/example/bucket_sorter.cpp b/example/bucket_sorter.cpp index c1751932..56b766da 100644 --- a/example/bucket_sorter.cpp +++ b/example/bucket_sorter.cpp @@ -37,9 +37,9 @@ int main() { cout << "Number " << i << " has its bucket " << bucket[i] << endl; } - typedef trivial_id ID; - typedef bucket_sorter::iterator, ID> BS; + using ID = trivial_id; + using BS = bucket_sorter::iterator, ID>; BS my_bucket_sorter(N, N, bucket.begin()); for (std::size_t ii=0; ii, property - > - graph; + >; // Create a maximal planar graph on 6 vertices graph g(6); @@ -60,7 +59,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - typedef std::vector< graph_traits::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits::edge_descriptor >; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = @@ -72,8 +71,7 @@ int main(int argc, char** argv) else std::cout << "Input graph is not planar" << std::endl; - typedef std::vector::vertex_descriptor> - ordering_storage_t; + using ordering_storage_t = std::vector::vertex_descriptor>; ordering_storage_t ordering; planar_canonical_ordering(g, diff --git a/example/city_visitor.cpp b/example/city_visitor.cpp index adf9f148..770584d0 100644 --- a/example/city_visitor.cpp +++ b/example/city_visitor.cpp @@ -58,7 +58,7 @@ using namespace boost; struct city_arrival : public base_visitor { city_arrival(string* n) : names(n) { } - typedef on_discover_vertex event_filter; + using event_filter = on_discover_vertex; template inline void operator()(Vertex u, Graph&) { cout << endl << "arriving at " << names[u] << endl @@ -70,7 +70,7 @@ struct city_arrival : public base_visitor struct neighbor_cities : public base_visitor { neighbor_cities(string* n) : names(n) { } - typedef on_examine_edge event_filter; + using event_filter = on_examine_edge; template inline void operator()(Edge e, Graph& g) { cout << names[ target(e, g) ] << ", "; @@ -81,7 +81,7 @@ struct neighbor_cities : public base_visitor struct finish_city : public base_visitor { finish_city(string* n) : names(n) { } - typedef on_finish_vertex event_filter; + using event_filter = on_finish_vertex; template inline void operator()(Vertex u, Graph&) { cout << endl << "finished with " << names[u] << endl; @@ -99,7 +99,7 @@ int main(int, char*[]) "Fresno", "Las Vegas", "Reno", "Sacramento", "Salt Lake City", "Phoenix" }; - typedef std::pair E; + using E = std::pair; E edge_array[] = { E(Sacramento, Reno), E(Sacramento, SanFran), E(Reno, SaltLake), E(SanFran, SanJose), @@ -108,7 +108,7 @@ int main(int, char*[]) E(LasVegas, Phoenix) }; /* Create the graph type we want. */ - typedef adjacency_list Graph; + using Graph = adjacency_list; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ has trouble with the edge iterator constructor Graph G(N); diff --git a/example/closeness_centrality.cpp b/example/closeness_centrality.cpp index ea921114..290eaf07 100644 --- a/example/closeness_centrality.cpp +++ b/example/closeness_centrality.cpp @@ -25,29 +25,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map WeightMap; +using WeightMap = constant_property_map; // Declare a container and its corresponding property map that // will contain the resulting closeness centralities of each // vertex in the graph. -typedef boost::exterior_vertex_property ClosenessProperty; -typedef ClosenessProperty::container_type ClosenessContainer; -typedef ClosenessProperty::map_type ClosenessMap; +using ClosenessProperty = boost::exterior_vertex_property; +using ClosenessContainer = ClosenessProperty::container_type; +using ClosenessMap = ClosenessProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index ad17ea2e..bde6be69 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -24,19 +24,19 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // The clustering property, container, and map define the containment // and abstract accessor for the clustering coefficients of vertices. -typedef exterior_vertex_property ClusteringProperty; -typedef ClusteringProperty::container_type ClusteringContainer; -typedef ClusteringProperty::map_type ClusteringMap; +using ClusteringProperty = exterior_vertex_property; +using ClusteringContainer = ClusteringProperty::container_type; +using ClusteringMap = ClusteringProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/components_on_edgelist.cpp b/example/components_on_edgelist.cpp index 685f86eb..5817c465 100644 --- a/example/components_on_edgelist.cpp +++ b/example/components_on_edgelist.cpp @@ -55,8 +55,8 @@ using boost::tie; int main(int , char* []) { using namespace boost; - typedef int Index; // ID of a Vertex - typedef pair Edge; + using Index = int; // ID of a Vertex + using Edge = pair; const int N = 6; const int E = 4; Edge edgelist[] = { Edge(0, 1), Edge(1, 4), Edge(4, 0), Edge(2, 5) }; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 12702944..9e556afc 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -15,7 +15,7 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, undirectedS > Graph; + using Graph = adjacency_list < vecS, vecS, undirectedS >; const int N = 6; Graph G(N); diff --git a/example/connected_components.cpp b/example/connected_components.cpp index bca8b0e9..3640f42c 100644 --- a/example/connected_components.cpp +++ b/example/connected_components.cpp @@ -40,7 +40,7 @@ int main(int , char* []) { using namespace boost; { - typedef adjacency_list Graph; + using Graph = adjacency_list ; Graph G; add_edge(0, 1, G); diff --git a/example/container_gen.cpp b/example/container_gen.cpp index 298e3a62..1dbfe079 100644 --- a/example/container_gen.cpp +++ b/example/container_gen.cpp @@ -16,19 +16,19 @@ struct list_with_allocatorS { }; namespace boost { template struct container_gen, ValueType> { - typedef typename Alloc::template rebind::other Allocator; - typedef std::list type; + using Allocator = typename Alloc::template rebind::other; + using type = std::list; }; template struct parallel_edge_traits< list_with_allocatorS > { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; } // now you can define a graph using std::list and a specific allocator -typedef boost::adjacency_list< list_with_allocatorS< std::allocator >, - boost::vecS, boost::directedS> MyGraph; +using MyGraph = boost::adjacency_list< list_with_allocatorS< std::allocator >, + boost::vecS, boost::directedS>; int main(int, char*[]) { diff --git a/example/copy-example.cpp b/example/copy-example.cpp index a78e036a..07b51404 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -15,8 +15,8 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, char > > graph_t; + using graph_t = adjacency_list < vecS, vecS, directedS, + property < vertex_name_t, char > >; enum { a, b, c, d, e, f, g, N }; @@ -27,7 +27,7 @@ main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/csr-example.cpp b/example/csr-example.cpp index b597193a..cc2191f9 100644 --- a/example/csr-example.cpp +++ b/example/csr-example.cpp @@ -23,7 +23,7 @@ class WebPage int main() { - typedef std::pair E; + using E = std::pair; const char* urls[6] = { "http://www.boost.org/libs/graph/doc/index.html", "http://www.boost.org/libs/graph/doc/table_of_contents.html", @@ -37,7 +37,7 @@ int main() E(2, 0), E(2, 5), E(3, 1), E(3, 4), E(4, 1), E(5, 0), E(5, 2) }; - typedef compressed_sparse_row_graph WebGraph; + using WebGraph = compressed_sparse_row_graph; WebGraph g(boost::edges_are_sorted, &the_edges[0], &the_edges[0] + sizeof(the_edges)/sizeof(E), 6); // Set the URLs of each vertex diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 2838f1d7..580a79e9 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -33,13 +33,13 @@ int main(int , char* []) { using namespace boost; using namespace std; - typedef adjacency_list > > Graph; - typedef graph_traits::vertex_descriptor Vertex; - typedef graph_traits::vertices_size_type size_type; + property > >; + using Vertex = graph_traits::vertex_descriptor; + using size_type = graph_traits::vertices_size_type; - typedef std::pair Pair; + using Pair = std::pair; Pair edges[14] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index b7b22fac..9577c110 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -24,13 +24,13 @@ namespace std } } -typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The file dependency graph is directed -> file_dep_graph; +>; -typedef graph_traits < file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits < file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits < file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits < file_dep_graph >::edge_descriptor; bool has_cycle_dfs(const file_dep_graph & g, vertex_t u, @@ -65,7 +65,7 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits < file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits < file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index 0b04ff41..3906431d 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -26,14 +26,14 @@ namespace std { } } -typedef adjacency_list< +using file_dep_graph = adjacency_list< listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The file dependency graph is directed - > file_dep_graph; + >; -typedef graph_traits::vertex_descriptor vertex_t; -typedef graph_traits::edge_descriptor edge_t; +using vertex_t = graph_traits::vertex_descriptor; +using edge_t = graph_traits::edge_descriptor; template < typename Visitor > void dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, @@ -122,7 +122,7 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits ::vertices_size_type size_type; + using size_type = graph_traits ::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index e08cc7f6..98b19f96 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -18,13 +18,13 @@ */ using namespace boost; -typedef adjacency_list< +using grap_real_t = adjacency_list< listS, listS, directedS, property, property< edge_weight_t, double, property > -> grap_real_t; +>; template void gen_rand_graph(TG &g, size_t nV, size_t nE) @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) using std::endl; const double epsilon = 0.0000001; double min_cr, max_cr; ///Minimum and maximum cycle ratio - typedef std::vector::edge_descriptor> ccReal_t; + using ccReal_t = std::vector::edge_descriptor>; ccReal_t cc; ///critical cycle grap_real_t tgr; diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 93eec25a..17563bda 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -25,8 +25,8 @@ int main() { using namespace boost; - typedef adjacency_list, property > graph_t; + using graph_t = adjacency_list, property >; graph_t g(6); enum verts { r, s, t, u, v, x }; char name[] = "rstuvx"; diff --git a/example/dave.cpp b/example/dave.cpp index 048dbd24..1972c3ba 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -71,12 +71,12 @@ b(14); d a */ -typedef property > VProperty; -typedef int weight_t; -typedef property EProperty; +using VProperty = property >; +using weight_t = int; +using EProperty = property; -typedef adjacency_list Graph; +using Graph = adjacency_list; @@ -84,7 +84,7 @@ template struct endl_printer : public boost::base_visitor< endl_printer > { - typedef Tag event_filter; + using event_filter = Tag; endl_printer(std::ostream& os) : m_os(os) { } template void operator()(T, Graph&) { m_os << std::endl; } @@ -99,7 +99,7 @@ template struct edge_printer : public boost::base_visitor< edge_printer > { - typedef Tag event_filter; + using event_filter = Tag; edge_printer(PA pa, std::ostream& os) : m_pa(pa), m_os(os) { } @@ -122,7 +122,7 @@ template struct graph_copier : public boost::base_visitor > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) { } @@ -165,10 +165,10 @@ main(int , char* []) auto vertex_id = get(vertex_index, G); std::vector distance(N, (numeric_limits::max)()); - typedef boost::graph_traits::vertex_descriptor Vertex; + using Vertex = boost::graph_traits::vertex_descriptor; std::vector parent(N); - typedef std::pair E; + using E = std::pair; E edges[] = { E(a,c), E(a,d), E(b,a), E(b,d), diff --git a/example/default-constructor.cpp b/example/default-constructor.cpp index 9d9f41a2..dc3a4dc6 100644 --- a/example/default-constructor.cpp +++ b/example/default-constructor.cpp @@ -14,7 +14,7 @@ using namespace boost; template < typename Graph > void read_graph_file(std::istream & in, Graph & g) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) // Add n vertices to the graph @@ -31,10 +31,10 @@ read_graph_file(std::istream & in, Graph & g) int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in("makefile-dependencies.dat"); diff --git a/example/default-constructor2.cpp b/example/default-constructor2.cpp index 173f10bf..cc89a410 100644 --- a/example/default-constructor2.cpp +++ b/example/default-constructor2.cpp @@ -14,8 +14,8 @@ using namespace boost; template < typename Graph > void read_graph_file(std::istream & in, Graph & g) { - typedef typename graph_traits < Graph >::vertex_descriptor Vertex; - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using Vertex = typename graph_traits < Graph >::vertex_descriptor; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices std::vector < Vertex > vertex_set(n_vertices); @@ -34,10 +34,10 @@ read_graph_file(std::istream & in, Graph & g) int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in("makefile-dependencies.dat"); diff --git a/example/degree_centrality.cpp b/example/degree_centrality.cpp index a8aae31c..d6079dce 100644 --- a/example/degree_centrality.cpp +++ b/example/degree_centrality.cpp @@ -25,19 +25,19 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a container type for degree centralities and its // corresponding property map. -typedef exterior_vertex_property CentralityProperty; -typedef CentralityProperty::container_type CentralityContainer; -typedef CentralityProperty::map_type CentralityMap; +using CentralityProperty = exterior_vertex_property; +using CentralityContainer = CentralityProperty::container_type; +using CentralityMap = CentralityProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/dfs-example.cpp b/example/dfs-example.cpp index 0117b81d..876de223 100644 --- a/example/dfs-example.cpp +++ b/example/dfs-example.cpp @@ -14,7 +14,7 @@ using namespace boost; template < typename TimeMap > class dfs_time_visitor:public default_dfs_visitor { - typedef typename property_traits < TimeMap >::value_type T; + using T = typename property_traits < TimeMap >::value_type; public: dfs_time_visitor(TimeMap dmap, TimeMap fmap, T & t) : m_dtimemap(dmap), m_ftimemap(fmap), m_time(t) { @@ -39,14 +39,14 @@ int main() { // Select the graph type we wish to use - typedef adjacency_list < vecS, vecS, directedS > graph_t; - typedef graph_traits < graph_t >::vertices_size_type size_type; + using graph_t = adjacency_list < vecS, vecS, directedS >; + using size_type = graph_traits < graph_t >::vertices_size_type; // Set up the vertex names enum { u, v, w, x, y, z, N }; char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' }; // Specify the edges in the graph - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edge_array[] = { E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y), E(w, z), E(z, z) }; @@ -61,10 +61,9 @@ main() // discover time and finish time properties std::vector < size_type > dtime(num_vertices(g)); std::vector < size_type > ftime(num_vertices(g)); - typedef + using time_pm_type = iterator_property_map::iterator, - property_map::const_type> - time_pm_type; + property_map::const_type>; time_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); time_pm_type ftime_pm(ftime.begin(), get(vertex_index, g)); size_type t = 0; diff --git a/example/dfs.cpp b/example/dfs.cpp index 8d68a09f..fbe03c87 100644 --- a/example/dfs.cpp +++ b/example/dfs.cpp @@ -53,7 +53,7 @@ using namespace std; template struct edge_categorizer : public dfs_visitor { - typedef dfs_visitor Base; + using Base = dfs_visitor; edge_categorizer(const VisitorList& v = null_visitor()) : Base(v) { } @@ -94,7 +94,7 @@ main(int , char* []) using namespace boost; - typedef adjacency_list<> Graph; + using Graph = adjacency_list<>; Graph G(5); add_edge(0, 2, G); @@ -107,7 +107,7 @@ main(int , char* []) add_edge(4, 0, G); add_edge(4, 1, G); - typedef graph_traits::vertices_size_type size_type; + using size_type = graph_traits::vertices_size_type; std::vector d(num_vertices(G)); std::vector f(num_vertices(G)); diff --git a/example/dfs_parenthesis.cpp b/example/dfs_parenthesis.cpp index 6f03401e..151f087c 100644 --- a/example/dfs_parenthesis.cpp +++ b/example/dfs_parenthesis.cpp @@ -28,14 +28,14 @@ using namespace boost; using namespace std; struct open_paren : public base_visitor { - typedef on_discover_vertex event_filter; + using event_filter = on_discover_vertex; template void operator()(Vertex v, Graph&) { std::cout << "(" << v; } }; struct close_paren : public base_visitor { - typedef on_finish_vertex event_filter; + using event_filter = on_finish_vertex; template void operator()(Vertex v, Graph&) { std::cout << v << ")"; @@ -49,8 +49,8 @@ main(int, char*[]) using namespace boost; - typedef adjacency_list<> Graph; - typedef std::pair E; + using Graph = adjacency_list<>; + using E = std::pair; E edge_array[] = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index b6fffd46..07cc1694 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -18,15 +18,15 @@ using namespace boost; int main(int, char *[]) { - typedef adjacency_list_traits::vertex_descriptor vertex_descriptor; - typedef adjacency_list < listS, listS, directedS, + using vertex_descriptor = adjacency_list_traits::vertex_descriptor; + using graph_t = adjacency_list < listS, listS, directedS, property > > >, - property > graph_t; - typedef std::pair Edge; + property >; + using Edge = std::pair; const int num_nodes = 5; enum nodes { A, B, C, D, E }; diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 7a04ef39..2cb8f1ee 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -19,10 +19,10 @@ using namespace boost; int main(int, char *[]) { - typedef adjacency_list < listS, vecS, directedS, - no_property, property < edge_weight_t, int > > graph_t; - typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor; - typedef std::pair Edge; + using graph_t = adjacency_list < listS, vecS, directedS, + no_property, property < edge_weight_t, int > >; + using vertex_descriptor = graph_traits < graph_t >::vertex_descriptor; + using Edge = std::pair; const int num_nodes = 5; enum nodes { A, B, C, D, E }; diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index 78e8249c..147cf161 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -23,10 +23,10 @@ using namespace boost; int main(int, char *[]) { - typedef adjacency_list < listS, vecS, directedS, - no_property, property < edge_weight_t, int > > graph_t; - typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor; - typedef std::pair Edge; + using graph_t = adjacency_list < listS, vecS, directedS, + no_property, property < edge_weight_t, int > >; + using vertex_descriptor = graph_traits < graph_t >::vertex_descriptor; + using Edge = std::pair; const int num_nodes = 5; enum nodes { A, B, C, D, E }; diff --git a/example/directed_graph.cpp b/example/directed_graph.cpp index 52aeca54..15ca176a 100644 --- a/example/directed_graph.cpp +++ b/example/directed_graph.cpp @@ -15,7 +15,7 @@ int main(int,char*[]) // like add_vertex and add_edge, which makes the code easier to understand. However, it hard codes many // of the template parameters, so it is much less flexible. - typedef boost::directed_graph<> Graph; + using Graph = boost::directed_graph<>; Graph g; auto v0 = g.add_vertex(); auto v1 = g.add_vertex(); diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index 3e16e6f2..b9c4de5e 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -25,29 +25,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map WeightMap; +using WeightMap = constant_property_map; // Declare a container and its corresponding property map that // will contain the resulting eccentricities of each vertex in // the graph. -typedef boost::exterior_vertex_property EccentricityProperty; -typedef EccentricityProperty::container_type EccentricityContainer; -typedef EccentricityProperty::map_type EccentricityMap; +using EccentricityProperty = boost::exterior_vertex_property; +using EccentricityContainer = EccentricityProperty::container_type; +using EccentricityMap = EccentricityProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index fc0786c6..754db2e9 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -21,7 +21,7 @@ namespace boost min_degree_vertex(Graph & g) { typename graph_traits < Graph >::vertex_descriptor p; - typedef typename graph_traits < Graph >::degree_size_type size_type; + using size_type = typename graph_traits < Graph >::degree_size_type; auto delta = (std::numeric_limits < size_type >::max)(); typename graph_traits < Graph >::vertex_iterator i, iend; for (boost::tie(i, iend) = vertices(g); i != iend; ++i) @@ -56,17 +56,17 @@ namespace boost typename graph_traits < VertexListGraph >::degree_size_type edge_connectivity(VertexListGraph & g, OutputIterator disconnecting_set) { - typedef typename graph_traits < - VertexListGraph >::vertex_descriptor vertex_descriptor; - typedef typename graph_traits < - VertexListGraph >::degree_size_type degree_size_type; - typedef color_traits < default_color_type > Color; - typedef typename adjacency_list_traits < vecS, vecS, - directedS >::edge_descriptor edge_descriptor; - typedef adjacency_list < vecS, vecS, directedS, no_property, + using vertex_descriptor = typename graph_traits < + VertexListGraph >::vertex_descriptor; + using degree_size_type = typename graph_traits < + VertexListGraph >::degree_size_type; + using Color = color_traits < default_color_type >; + using edge_descriptor = typename adjacency_list_traits < vecS, vecS, + directedS >::edge_descriptor; + using FlowGraph = adjacency_list < vecS, vecS, directedS, no_property, property < edge_capacity_t, degree_size_type, property < edge_residual_capacity_t, degree_size_type, - property < edge_reverse_t, edge_descriptor > > > > FlowGraph; + property < edge_reverse_t, edge_descriptor > > > >; vertex_descriptor u, v, p, k; edge_descriptor e1, e2; @@ -150,7 +150,7 @@ main() GraphvizGraph g; read_graphviz("figs/edge-connectivity.dot", g); - typedef graph_traits < GraphvizGraph >::edge_descriptor edge_descriptor; + using edge_descriptor = graph_traits < GraphvizGraph >::edge_descriptor; std::vector < edge_descriptor > disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); diff --git a/example/edge-function.cpp b/example/edge-function.cpp index ca2b3abd..bcc11db6 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -75,11 +75,11 @@ name_equals(const std::string & str, NameMap name) int main() { - typedef adjacency_list // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; diff --git a/example/edge-iter-constructor.cpp b/example/edge-iter-constructor.cpp index d9f616aa..2642ef16 100644 --- a/example/edge-iter-constructor.cpp +++ b/example/edge-iter-constructor.cpp @@ -22,14 +22,14 @@ template < typename T > int main() { - typedef adjacency_list < + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > graph_type; + >; std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits < graph_type >::vertices_size_type size_type; + using size_type = graph_traits < graph_type >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index ee7e7921..48729c2b 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -43,8 +43,8 @@ template struct exercise_edge { exercise_edge(Graph& g) : G(g) {} - typedef typename boost::graph_traits::edge_descriptor Edge; - typedef typename boost::graph_traits::vertex_descriptor Vertex; + using Edge = typename boost::graph_traits::edge_descriptor; + using Vertex = typename boost::graph_traits::vertex_descriptor; void operator()(Edge e) const { //begin @@ -67,9 +67,9 @@ struct exercise_edge { int main() { - typedef adjacency_list<> MyGraph; + using MyGraph = adjacency_list<>; - typedef pair Pair; + using Pair = pair; Pair edge_array[8] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1) }; diff --git a/example/edge_coloring.cpp b/example/edge_coloring.cpp index 1a752fd1..76e84c1b 100644 --- a/example/edge_coloring.cpp +++ b/example/edge_coloring.cpp @@ -36,9 +36,9 @@ int main(int, char *[]) { using namespace boost; using namespace std; - typedef adjacency_list Graph; + using Graph = adjacency_list; - typedef std::pair Pair; + using Pair = std::pair; Pair edges[14] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c diff --git a/example/edge_connectivity.cpp b/example/edge_connectivity.cpp index da3dcd60..ccc7a654 100644 --- a/example/edge_connectivity.cpp +++ b/example/edge_connectivity.cpp @@ -22,7 +22,7 @@ int main() { const int N = 8; - typedef adjacency_list UndirectedGraph; + using UndirectedGraph = adjacency_list; UndirectedGraph g(N); add_edge(0, 1, g); @@ -40,8 +40,8 @@ main() add_edge(5, 7, g); add_edge(6, 7, g); - typedef graph_traits::edge_descriptor edge_descriptor; - typedef graph_traits::degree_size_type degree_size_type; + using edge_descriptor = graph_traits::edge_descriptor; + using degree_size_type = graph_traits::degree_size_type; std::vector disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index 4a42357d..4624f5b8 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -43,11 +43,11 @@ class edge_stream_iterator { public: - typedef std::input_iterator_tag iterator_category; - typedef std::pair value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; + using iterator_category = std::input_iterator_tag ; + using value_type = std::pair ; + using difference_type = std::ptrdiff_t ; + using pointer = const value_type* ; + using reference = const value_type& ; edge_stream_iterator() : m_stream(0), m_end_marker(false) {} edge_stream_iterator(std::istream& s) : m_stream(&s) { m_read(); } @@ -93,8 +93,8 @@ bool operator!=(const edge_stream_iterator& x, int main() { - typedef boost::adjacency_list<> IteratorConstructibleGraph; - typedef boost::graph_traits Traits; + using IteratorConstructibleGraph = boost::adjacency_list<>; + using Traits = boost::graph_traits; Traits::vertices_size_type size_V; Traits::edges_size_type size_E; diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 1a152984..fd041c87 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -72,9 +72,9 @@ namespace boost { template void print_network(const Graph& G) { - typedef typename boost::graph_traits::vertex_iterator Viter; - typedef typename boost::graph_traits::out_edge_iterator OutEdgeIter; - typedef typename boost::graph_traits::in_edge_iterator InEdgeIter; + using Viter = typename boost::graph_traits::vertex_iterator ; + using OutEdgeIter = typename boost::graph_traits::out_edge_iterator; + using InEdgeIter = typename boost::graph_traits::in_edge_iterator; auto capacity = get(edge_mycapacity, G); auto flow = get(edge_myflow, G); @@ -105,10 +105,10 @@ void print_network(const Graph& G) int main(int , char* []) { - typedef property Cap; - typedef property Flow; - typedef adjacency_list Graph; + using Cap = property; + using Flow = property; + using Graph = adjacency_list; const int num_vertices = 9; Graph G(num_vertices); diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index 38060972..04ddc1ec 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -47,12 +47,12 @@ main() { using namespace boost; - typedef adjacency_list_traits < vecS, vecS, directedS > Traits; - typedef adjacency_list < listS, vecS, directedS, + using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Graph = adjacency_list < listS, vecS, directedS, property < vertex_name_t, std::string >, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; + property < edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index 3ca4edc3..df4b554d 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -41,9 +41,9 @@ template void print_network(Graph& G, Capacity capacity, Flow flow) { - typedef typename boost::graph_traits::vertex_iterator Viter; - typedef typename boost::graph_traits::out_edge_iterator OutEdgeIter; - typedef typename boost::graph_traits::in_edge_iterator InEdgeIter; + using Viter = typename boost::graph_traits::vertex_iterator ; + using OutEdgeIter = typename boost::graph_traits::out_edge_iterator; + using InEdgeIter = typename boost::graph_traits::in_edge_iterator; Viter ui, uiend; for (boost::tie(ui, uiend) = boost::vertices(G); ui != uiend; ++ui) { @@ -66,9 +66,9 @@ void print_network(Graph& G, Capacity capacity, Flow flow) int main(int , char* []) { - typedef boost::adjacency_list > Graph; + boost::property >; const int num_vertices = 9; Graph G(num_vertices); @@ -104,10 +104,10 @@ int main(int , char* []) { boost::add_edge(6, 8, 9, G); - typedef boost::property_map::type EdgeIndexMap; + using EdgeIndexMap = boost::property_map::type; EdgeIndexMap edge_id = boost::get(boost::edge_index, G); - typedef boost::iterator_property_map IterMap; + using IterMap = boost::iterator_property_map; print_network(G, IterMap(capacity, edge_id), IterMap(flow, edge_id)); diff --git a/example/exterior_property_map.cpp b/example/exterior_property_map.cpp index 9b9ac79e..555142fa 100644 --- a/example/exterior_property_map.cpp +++ b/example/exterior_property_map.cpp @@ -77,9 +77,9 @@ main(int, char*[]) names[3] = "Jeff"; names[4] = "Kinis"; - typedef adjacency_list<> MyGraphType; + using MyGraphType = adjacency_list<>; - typedef pair Pair; + using Pair = pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index 7eefa194..dde54187 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -21,7 +21,7 @@ using namespace boost; int main() { - typedef indirect_cmp > ICmp; + using ICmp = indirect_cmp >; int i; boost::mt19937 gen; for (int N = 2; N < 200; ++N) { diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index 9bce7334..1d053e51 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -79,7 +79,7 @@ struct cycle_detector : public dfs_visitor<> int main(int,char*[]) { - typedef pair Edge; + using Edge = pair; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), @@ -98,7 +98,7 @@ int main(int,char*[]) }; const std::size_t nedges = sizeof(used_by)/sizeof(Edge); - typedef adjacency_list Graph; + using Graph = adjacency_list; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor Graph g(N); @@ -109,12 +109,12 @@ int main(int,char*[]) #else Graph g(used_by, used_by + nedges, N); #endif - typedef graph_traits::vertex_descriptor Vertex; + using Vertex = graph_traits::vertex_descriptor; // Determine ordering for a full recompilation // and the order with files that can be compiled in parallel { - typedef list MakeOrder; + using MakeOrder = list; MakeOrder::iterator i; MakeOrder make_order; diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index e86c00ea..1af58223 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -29,8 +29,8 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, bidirectionalS, - property < vertex_name_t, char > > graph_t; + using graph_t = adjacency_list < vecS, vecS, bidirectionalS, + property < vertex_name_t, char > >; enum { a, b, c, d, e, f, g, N }; graph_t G(N); @@ -40,7 +40,7 @@ main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/filtered_graph.cpp b/example/filtered_graph.cpp index e325b5f8..df831008 100644 --- a/example/filtered_graph.cpp +++ b/example/filtered_graph.cpp @@ -41,9 +41,9 @@ int main() { using namespace boost; - typedef adjacency_list > Graph; - typedef property_map::type EdgeWeightMap; + using Graph = adjacency_list >; + using EdgeWeightMap = property_map::type; enum { A, B, C, D, E, N }; const char* name = "ABCDE"; diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index 9ac5f0d4..ccbcece8 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -43,6 +43,7 @@ int main() using Graph = adjacency_list>; + using EdgeWeightMap = property_map::type; enum { A, B, C, D, E, N }; const char* name = "ABCDE"; @@ -65,7 +66,7 @@ int main() << "-> " << name[target(*f, g)] << "\n"; positive_edge_weight filter(weight); - typedef filtered_graph > FGraph; + using FGraph = filtered_graph >; FGraph fg(g, filter); std::cout << "filtered edge_range(C,D)\n"; diff --git a/example/filtered_vec_as_graph.cpp b/example/filtered_vec_as_graph.cpp index 615cd72d..4a59a1d3 100644 --- a/example/filtered_vec_as_graph.cpp +++ b/example/filtered_vec_as_graph.cpp @@ -40,7 +40,7 @@ int main() enum { A, B, C, D, E }; const char* name = "ABCDE"; - typedef std::vector < std::list < int > > Graph; + using Graph = std::vector < std::list < int > >; Graph g = { {B, C}, //A {}, //B diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 2f7e4fea..0a4cf004 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -37,15 +37,15 @@ void usage() << " Vertices and their positions are written to standard output with the label,\n x-position, and y-position of a vertex on each line, separated by spaces.\n"; } -typedef boost::rectangle_topology<> topology_type; -typedef topology_type::point_type point_type; +using topology_type = boost::rectangle_topology<>; +using point_type = topology_type::point_type; -typedef adjacency_list > Graph; +using Graph = adjacency_list >; -typedef graph_traits::vertex_descriptor Vertex; +using Vertex = graph_traits::vertex_descriptor; -typedef std::map NameToVertex; +using NameToVertex = std::map; Vertex get_vertex(const std::string& name, Graph& g, NameToVertex& names) { @@ -57,7 +57,7 @@ Vertex get_vertex(const std::string& name, Graph& g, NameToVertex& names) class progress_cooling : public linear_cooling { - typedef linear_cooling inherited; + using inherited = linear_cooling; public: explicit progress_cooling(std::size_t iterations) : inherited(iterations) @@ -113,11 +113,10 @@ int main(int argc, char* argv[]) add_edge(get_vertex(source, g, names), get_vertex(target, g, names), g); } - typedef std::vector PositionVec; + using PositionVec = std::vector; PositionVec position_vec(num_vertices(g)); - typedef iterator_property_map::type> - PositionMap; + using PositionMap = iterator_property_map::type>; PositionMap position(position_vec.begin(), get(vertex_index, g)); minstd_rand gen; diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index c01dd6e8..b660536b 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -43,7 +43,7 @@ void merge_vertex typename boost::graph_traits::vertex_descriptor v, Graph& g, GetEdgeProperties getp) { - typedef boost::graph_traits Traits; + using Traits = boost::graph_traits; typename Traits::edge_descriptor e; typename Traits::out_edge_iterator out_i, out_end; for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { @@ -78,11 +78,11 @@ struct ordered_set_by_nameS { }; namespace boost { template struct container_gen { - typedef std::set > type; + using type = std::set >; }; template <> struct parallel_edge_traits { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; } #endif @@ -105,9 +105,9 @@ main() std::cout << "This program requires partial specialization." << std::endl; #else using namespace boost; - typedef property EdgeProperty; - typedef adjacency_list graph_type; + using EdgeProperty = property; + using graph_type = adjacency_list ; graph_type g; diff --git a/example/girth.cpp b/example/girth.cpp index 728c5739..831461f6 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -49,20 +49,20 @@ #include #include -typedef boost::graph_traits Traits; -typedef Traits::vertex_descriptor vertex_descriptor; -typedef Traits::edge_descriptor edge_descriptor; -typedef Traits::vertex_iterator vertex_iterator; +using Traits = boost::graph_traits; +using vertex_descriptor = Traits::vertex_descriptor; +using edge_descriptor = Traits::edge_descriptor; +using vertex_iterator = Traits::vertex_iterator; std::vector distance_list; -typedef boost::v_property dist_t; +using dist_t = boost::v_property; boost::property_map::type d_map; -typedef boost::u_property pred_t; +using pred_t = boost::u_property; boost::property_map::type p_map; -typedef boost::w_property color_t; +using color_t = boost::w_property; boost::property_map::type c_map; class diameter_and_girth_visitor : public boost::bfs_visitor<> diff --git a/example/graph-assoc-types.cpp b/example/graph-assoc-types.cpp index aedeebca..48b38956 100644 --- a/example/graph-assoc-types.cpp +++ b/example/graph-assoc-types.cpp @@ -14,11 +14,11 @@ template < typename Graph > void generic_foo(Graph & g) { // Access descriptor types - typedef typename graph_traits < Graph >::vertex_descriptor Vertex; - typedef typename graph_traits < Graph >::edge_descriptor Edge; + using Vertex = typename graph_traits < Graph >::vertex_descriptor; + using Edge = typename graph_traits < Graph >::edge_descriptor; // Access category types - typedef typename graph_traits < Graph >::directed_category Dir; - typedef typename graph_traits < Graph >::edge_parallel_category Par; + using Dir = typename graph_traits < Graph >::directed_category; + using Par = typename graph_traits < Graph >::edge_parallel_category; // Access iterator types... // Access size types... // Now do something useful... @@ -56,7 +56,7 @@ foo_dispatch(Graph & g, boost::undirected_tag) template < typename Graph > void foo(Graph & g) { - typedef typename boost::graph_traits < Graph >::directed_category Cat; + using Cat = typename boost::graph_traits < Graph >::directed_category; foo_dispatch(g, Cat()); } @@ -65,7 +65,7 @@ foo(Digraph & digraph, typename graph_traits < Digraph >::vertex_descriptor u, typename graph_traits < Digraph >::vertex_descriptor v) { - typedef typename graph_traits < Digraph >::edge_descriptor edge_t; + using edge_t = typename graph_traits < Digraph >::edge_descriptor; std::pair e1, e2; e1 = edge(u, v, digraph); e2 = edge(v, u, digraph); @@ -76,7 +76,7 @@ bar(Undigraph & undigraph, typename graph_traits < Undigraph >::vertex_descriptor u, typename graph_traits < Undigraph >::vertex_descriptor v) { - typedef typename graph_traits < Undigraph >::edge_descriptor edge_t; + using edge_t = typename graph_traits < Undigraph >::edge_descriptor; std::pair e1, e2; e1 = edge(u, v, undigraph); e2 = edge(v, u, undigraph); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index 0c11914a..4200334f 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -16,8 +16,8 @@ int main() { using namespace boost; - typedef adjacency_list < listS, vecS, directedS, - property < vertex_name_t, std::string > >graph_t; + using graph_t = adjacency_list < listS, vecS, directedS, + property < vertex_name_t, std::string > >; graph_t g(3); const char *vertex_names[] = { "Kubrick", "Clark", "Hal" }; diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index 648149a9..8db6992c 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -25,23 +25,23 @@ using namespace std; // // Create a custom graph properties // (see the documentation for adjacency list) -struct graph_identifier_t { typedef graph_property_tag kind; }; -struct vertex_label_t { typedef vertex_property_tag kind; }; +struct graph_identifier_t { using kind = graph_property_tag; }; +struct vertex_label_t { using kind = vertex_property_tag; }; int main() { // Vertex properties - typedef property < vertex_name_t, string, + using vertex_p = property < vertex_name_t, string, property < vertex_label_t, string, - property < vertex_root_t, int > > > vertex_p; + property < vertex_root_t, int > > >; // Edge properties - typedef property < edge_name_t, string > edge_p; + using edge_p = property < edge_name_t, string >; // Graph properties - typedef property < graph_name_t, string, - property < graph_identifier_t, string > > graph_p; + using graph_p = property < graph_name_t, string, + property < graph_identifier_t, string > >; // adjacency_list-based type - typedef adjacency_list < vecS, vecS, directedS, - vertex_p, edge_p, graph_p > graph_t; + using graph_t = adjacency_list < vecS, vecS, directedS, + vertex_p, edge_p, graph_p >; // Construct an empty graph and prepare the dynamic_property_maps. graph_t graph(0); diff --git a/example/graph.cpp b/example/graph.cpp index c73fba7b..b9181872 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -17,14 +17,14 @@ using namespace boost; using namespace std; -typedef property > > > > VertexProperty; -typedef property EdgeProperty; -typedef adjacency_list Graph; + property > > > >; +using EdgeProperty = property; +using Graph = adjacency_list; template void print(Graph& g) { diff --git a/example/graph_as_tree.cpp b/example/graph_as_tree.cpp index 03677106..fa115ca0 100644 --- a/example/graph_as_tree.cpp +++ b/example/graph_as_tree.cpp @@ -33,9 +33,9 @@ class tree_printer { int main() { using namespace boost; - typedef adjacency_list > graph_t; - typedef graph_traits::vertex_descriptor vertex_t; + using graph_t = adjacency_list >; + using vertex_t = graph_traits::vertex_descriptor; graph_t g; @@ -51,10 +51,10 @@ int main() name[b] = "B"; name[c] = "C"; - typedef iterator_property_map::iterator, - property_map::type> parent_map_t; + using parent_map_t = iterator_property_map::iterator, + property_map::type>; std::vector parent(num_vertices(g)); - typedef graph_as_tree tree_t; + using tree_t = graph_as_tree; tree_t t(g, a, make_iterator_property_map(parent.begin(), get(vertex_index, g))); diff --git a/example/graph_property.cpp b/example/graph_property.cpp index ceb71c47..6ba2859d 100644 --- a/example/graph_property.cpp +++ b/example/graph_property.cpp @@ -15,16 +15,16 @@ main() using namespace boost; using std::string; - typedef adjacency_list, - property > graph_t; + property >; graph_t g; get_property(g, graph_name) = "graph"; std::cout << "name: " << get_property(g, graph_name) << std::endl; - typedef subgraph subgraph_t; + using subgraph_t = subgraph; subgraph_t sg; get_property(sg, graph_name) = "subgraph"; diff --git a/example/graphviz.cpp b/example/graphviz.cpp index a21d8541..33735c01 100644 --- a/example/graphviz.cpp +++ b/example/graphviz.cpp @@ -14,13 +14,13 @@ using namespace boost; -typedef boost::adjacency_list, - property > Digraph; + property >; -typedef boost::adjacency_list, - property > Graph; + property >; void test_graph_read_write(const std::string& filename) { @@ -36,7 +36,7 @@ void test_graph_read_write(const std::string& filename) BOOST_CHECK(num_vertices(g) == 4); BOOST_CHECK(num_edges(g) == 4); - typedef graph_traits::vertex_descriptor Vertex; + using Vertex = graph_traits::vertex_descriptor; std::map name_to_vertex; BGL_FORALL_VERTICES(v, g, Graph) diff --git a/example/grid_graph_example.cpp b/example/grid_graph_example.cpp index 1406f2ef..796575ec 100644 --- a/example/grid_graph_example.cpp +++ b/example/grid_graph_example.cpp @@ -14,8 +14,8 @@ #define DIMENSIONS 3 using namespace boost; -typedef grid_graph Graph; -typedef graph_traits Traits; +using Graph = grid_graph; +using Traits = graph_traits; // Define a simple function to print vertices void print_vertex(Traits::vertex_descriptor vertex_to_print) { diff --git a/example/grid_graph_properties.cpp b/example/grid_graph_properties.cpp index 437f1216..22cb50e7 100644 --- a/example/grid_graph_properties.cpp +++ b/example/grid_graph_properties.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { // A 2D grid graph - typedef boost::grid_graph<2> GraphType; + using GraphType = boost::grid_graph<2>; // Create a 5x5 graph const unsigned int dimension = 5; @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) GraphType graph(lengths); // Get the index map of the grid graph - typedef boost::property_map::const_type indexMapType; + using indexMapType = boost::property_map::const_type; indexMapType indexMap(get(boost::vertex_index, graph)); // Create a float for every node in the graph diff --git a/example/hawick_circuits.cpp b/example/hawick_circuits.cpp index a861fc1f..bc838f76 100644 --- a/example/hawick_circuits.cpp +++ b/example/hawick_circuits.cpp @@ -50,8 +50,8 @@ struct cycle_printer template void build_graph(Graph& graph, unsigned int const nvertices, VertexPairIterator first, VertexPairIterator last) { - typedef boost::graph_traits Traits; - typedef typename Traits::vertex_descriptor vertex_descriptor; + using Traits = boost::graph_traits; + using vertex_descriptor = typename Traits::vertex_descriptor; std::map vertices; for (unsigned int i = 0; i < nvertices; ++i) diff --git a/example/helper.hpp b/example/helper.hpp index 1247618a..6a019dd8 100644 --- a/example/helper.hpp +++ b/example/helper.hpp @@ -18,8 +18,8 @@ template typename boost::graph_traits::vertex_descriptor add_named_vertex(Graph& g, NameMap nm, const std::string& name, VertexMap& vm) { - typedef typename boost::graph_traits::vertex_descriptor Vertex; - typedef typename VertexMap::iterator Iterator; + using Vertex = typename boost::graph_traits::vertex_descriptor; + using Iterator = typename VertexMap::iterator; Vertex v; Iterator iter; @@ -43,7 +43,7 @@ template inline std::map::vertex_descriptor> read_graph(Graph& g, NameMap nm, InputStream& is) { - typedef typename boost::graph_traits::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits::vertex_descriptor; std::map verts; for(std::string line; std::getline(is, line); ) { if(line.empty()) continue; @@ -62,8 +62,8 @@ template inline std::map::vertex_descriptor> read_graph(Graph& g, InputStream& is) { - typedef typename boost::graph_traits::vertex_descriptor Vertex; - typedef boost::null_property_map NameMap; + using Vertex = typename boost::graph_traits::vertex_descriptor; + using NameMap = boost::null_property_map; return read_graph(g, NameMap(), is); } @@ -71,8 +71,8 @@ template ::vertex_descriptor> read_weighted_graph(Graph& g, NameMap nm, WeightMap wm, InputStream& is) { - typedef typename boost::graph_traits::vertex_descriptor Vertex; - typedef typename boost::graph_traits::edge_descriptor Edge; + using Vertex = typename boost::graph_traits::vertex_descriptor; + using Edge = typename boost::graph_traits::edge_descriptor; std::map verts; for(std::string line; std::getline(is, line); ) { if(line.empty()) continue; @@ -103,8 +103,8 @@ template inline std::map::vertex_descriptor> read_weighted_graph(Graph& g, WeightMap wm, InputStream& is) { - typedef typename boost::graph_traits::vertex_descriptor Vertex; - typedef boost::null_property_map NameMap; + using Vertex = typename boost::graph_traits::vertex_descriptor; + using NameMap = boost::null_property_map; return read_weighted_graph(g, NameMap(), wm, is); } diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index 8ca1f5a6..22326800 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -92,14 +92,14 @@ struct edge_weight_map; namespace boost { template<> struct property_map< ring_graph, edge_weight_t > { - typedef edge_weight_map type; - typedef edge_weight_map const_type; + using type = edge_weight_map; + using const_type = edge_weight_map; }; template<> struct property_map< const ring_graph, edge_weight_t > { - typedef edge_weight_map type; - typedef edge_weight_map const_type; + using type = edge_weight_map; + using const_type = edge_weight_map; }; } @@ -121,35 +121,35 @@ indices. Vertex 0 is also adjacent to the vertex n-1. class ring_graph { public: // Graph associated types - typedef std::size_t vertex_descriptor; - typedef boost::undirected_tag directed_category; - typedef boost::disallow_parallel_edge_tag edge_parallel_category; - typedef ring_traversal_catetory traversal_category; + using vertex_descriptor = std::size_t; + using directed_category = boost::undirected_tag; + using edge_parallel_category = boost::disallow_parallel_edge_tag; + using traversal_category = ring_traversal_catetory; // IncidenceGraph associated types - typedef std::pair edge_descriptor; - typedef ring_incident_edge_iterator out_edge_iterator; - typedef std::size_t degree_size_type; + using edge_descriptor = std::pair; + using out_edge_iterator = ring_incident_edge_iterator; + using degree_size_type = std::size_t; // BidirectionalGraph associated types // Note that undirected graphs make no distinction between in- and out- // edges. - typedef ring_incident_edge_iterator in_edge_iterator; + using in_edge_iterator = ring_incident_edge_iterator; // AdjacencyGraph associated types - typedef ring_adjacency_iterator adjacency_iterator; + using adjacency_iterator = ring_adjacency_iterator; // VertexListGraph associated types - typedef boost::counting_iterator vertex_iterator; - typedef std::size_t vertices_size_type; + using vertex_iterator = boost::counting_iterator; + using vertices_size_type = std::size_t; // EdgeListGraph associated types - typedef ring_edge_iterator edge_iterator; - typedef std::size_t edges_size_type; + using edge_iterator = ring_edge_iterator; + using edges_size_type = std::size_t; // This type is not part of a graph concept, but is used to return the // default vertex index map used by the Dijkstra search algorithm. - typedef vertex_descriptor vertex_property_type; + using vertex_property_type = vertex_descriptor; ring_graph(std::size_t n):m_n(n) {}; std::size_t n() const {return m_n;} @@ -160,16 +160,16 @@ class ring_graph { // Use these graph_traits parameterizations to refer to the associated // graph types. -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::edge_descriptor edge_descriptor; -typedef boost::graph_traits::out_edge_iterator out_edge_iterator; -typedef boost::graph_traits::in_edge_iterator in_edge_iterator; -typedef boost::graph_traits::adjacency_iterator adjacency_iterator; -typedef boost::graph_traits::degree_size_type degree_size_type; -typedef boost::graph_traits::vertex_iterator vertex_iterator; -typedef boost::graph_traits::vertices_size_type vertices_size_type; -typedef boost::graph_traits::edge_iterator edge_iterator; -typedef boost::graph_traits::edges_size_type edges_size_type; +using vertex_descriptor = boost::graph_traits::vertex_descriptor; +using edge_descriptor = boost::graph_traits::edge_descriptor; +using out_edge_iterator = boost::graph_traits::out_edge_iterator; +using in_edge_iterator = boost::graph_traits::in_edge_iterator; +using adjacency_iterator = boost::graph_traits::adjacency_iterator; +using degree_size_type = boost::graph_traits::degree_size_type; +using vertex_iterator = boost::graph_traits::vertex_iterator; +using vertices_size_type = boost::graph_traits::vertices_size_type; +using edge_iterator = boost::graph_traits::edge_iterator; +using edges_size_type = boost::graph_traits::edges_size_type; // Tag values passed to an iterator constructor to specify whether it should @@ -287,10 +287,10 @@ class ring_adjacency_iterator:public boost::adjacency_iterator_generator< out_edge_iterator>::type { // The parent class is an iterator_adpator that turns an iterator over // out edges into an iterator over adjacent vertices. - typedef boost::adjacency_iterator_generator< + using parent_class = boost::adjacency_iterator_generator< ring_graph, vertex_descriptor, - out_edge_iterator>::type parent_class; + out_edge_iterator>::type; public: ring_adjacency_iterator() {}; ring_adjacency_iterator(vertex_descriptor u, @@ -392,10 +392,10 @@ edge(vertex_descriptor u, vertex_descriptor v, const ring_graph& g) { Map from edges to weight values */ struct edge_weight_map { - typedef double value_type; - typedef value_type reference; - typedef edge_descriptor key_type; - typedef boost::readable_property_map_tag category; + using value_type = double; + using reference = value_type; + using key_type = edge_descriptor; + using category = boost::readable_property_map_tag; // Edges have a weight equal to the average of their endpoint indexes. reference operator[](key_type e) const { @@ -405,13 +405,10 @@ struct edge_weight_map { // Use these propety_map and property_traits parameterizations to refer to // the associated property map types. -typedef boost::property_map::const_type - const_edge_weight_map; -typedef boost::property_traits::reference - edge_weight_map_value_type; -typedef boost::property_traits::key_type - edge_weight_map_key; +using const_edge_weight_map = boost::property_map::const_type; +using edge_weight_map_value_type = boost::property_traits::reference; +using edge_weight_map_key = boost::property_traits::key_type; // PropertyMap valid expressions edge_weight_map_value_type diff --git a/example/in_edges.cpp b/example/in_edges.cpp index f729c44d..b994d5cd 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -30,7 +30,7 @@ int main(int , char* []) using namespace std; using namespace boost; - typedef adjacency_list Graph; + using Graph = adjacency_list; const int num_vertices = 5; Graph g(num_vertices); diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index d825a27d..6cf23012 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -26,8 +26,8 @@ template > struct inclusive_average { - typedef DistanceType distance_type; - typedef ResultType result_type; + using distance_type = DistanceType; + using result_type = ResultType; result_type operator ()(distance_type d, const Graph& g) { @@ -56,30 +56,30 @@ struct Link }; // Declare the graph type and its vertex and edge types. -typedef directed_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = directed_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map as an accessor into the bundled // edge property. -typedef property_map::type WeightMap; +using WeightMap = property_map::type; // Declare a container and its corresponding property map that // will contain the resulting mean geodesic distances of each // vertex in the graph. -typedef exterior_vertex_property GeodesicProperty; -typedef GeodesicProperty::container_type GeodesicContainer; -typedef GeodesicProperty::map_type GeodesicMap; +using GeodesicProperty = exterior_vertex_property; +using GeodesicContainer = GeodesicProperty::container_type; +using GeodesicMap = GeodesicProperty::map_type; static float exclusive_geodesics(const Graph&, DistanceMatrixMap, GeodesicMap); static float inclusive_geodesics(const Graph&, DistanceMatrixMap, GeodesicMap); diff --git a/example/incremental-components-eg.cpp b/example/incremental-components-eg.cpp index 7faf4418..c2eeba5a 100644 --- a/example/incremental-components-eg.cpp +++ b/example/incremental-components-eg.cpp @@ -20,10 +20,10 @@ using namespace boost; int main(int argc, char* argv[]) { - typedef adjacency_list Graph; - typedef graph_traits::vertex_descriptor Vertex; - //typedef graph_traits::edge_descriptor Edge; - typedef graph_traits::vertices_size_type VertexIndex; + using Graph = adjacency_list ; + using Vertex = graph_traits::vertex_descriptor; + //using Edge = graph_traits::edge_descriptor; + using VertexIndex = graph_traits::vertices_size_type; // Create a graph const int VERTEX_COUNT = 6; @@ -37,8 +37,8 @@ int main(int argc, char* argv[]) std::vector rank(num_vertices(graph)); std::vector parent(num_vertices(graph)); - typedef VertexIndex* Rank; - typedef Vertex* Parent; + using Rank = VertexIndex*; + using Parent = Vertex*; disjoint_sets ds(&rank[0], &parent[0]); // Determine the connected components, storing the results in the @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) // index map into the component_index constructor if our graph type // used listS instead of vecS (identity_property_map is used by // default). - typedef component_index Components; + using Components = component_index; Components components(parent.begin(), parent.end()); // Iterate through the component indices diff --git a/example/incremental_components.cpp b/example/incremental_components.cpp index f8f156ef..a786f594 100644 --- a/example/incremental_components.cpp +++ b/example/incremental_components.cpp @@ -49,9 +49,9 @@ using namespace boost; int main(int argc, char* argv[]) { - typedef adjacency_list Graph; - typedef graph_traits::vertex_descriptor Vertex; - typedef graph_traits::vertices_size_type VertexIndex; + using Graph = adjacency_list ; + using Vertex = graph_traits::vertex_descriptor; + using VertexIndex = graph_traits::vertices_size_type; const int VERTEX_COUNT = 6; Graph graph(VERTEX_COUNT); @@ -59,8 +59,8 @@ int main(int argc, char* argv[]) std::vector rank(num_vertices(graph)); std::vector parent(num_vertices(graph)); - typedef VertexIndex* Rank; - typedef Vertex* Parent; + using Rank = VertexIndex*; + using Parent = Vertex*; disjoint_sets ds(&rank[0], &parent[0]); @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) std::cout << std::endl; - typedef component_index Components; + using Components = component_index; // NOTE: Because we're using vecS for the graph type, we're // effectively using identity_property_map for a vertex index map. diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index 43538168..f6b493bb 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -24,20 +24,20 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef directed_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = directed_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a container type for influence and prestige (both // of which are degree centralities) and its corresponding // property map. -typedef exterior_vertex_property CentralityProperty; -typedef CentralityProperty::container_type CentralityContainer; -typedef CentralityProperty::map_type CentralityMap; +using CentralityProperty = exterior_vertex_property; +using CentralityContainer = CentralityProperty::container_type; +using CentralityMap = CentralityProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/interior_pmap_bundled.cpp b/example/interior_pmap_bundled.cpp index cee50169..21e46ab6 100644 --- a/example/interior_pmap_bundled.cpp +++ b/example/interior_pmap_bundled.cpp @@ -66,9 +66,9 @@ main() { // Create the graph, and specify that we will use std::string to // store the first name's. - typedef adjacency_list MyGraphType; + using MyGraphType = adjacency_list; - typedef pair Pair; + using Pair = pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index fbe21f93..229b6f6e 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -55,11 +55,11 @@ template void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) { // Access the propety acessor type for this graph - typedef typename property_map - ::const_type NamePA; + using NamePA = typename property_map + ::const_type; auto name = get(vertex_first_name, G); - typedef typename boost::property_traits::value_type NameType; + using NameType = typename boost::property_traits::value_type; NameType src_name, targ_name; @@ -78,10 +78,10 @@ main() { // Create the graph, and specify that we will use std::string to // store the first name's. - typedef adjacency_list > MyGraphType; + using MyGraphType = adjacency_list >; - typedef pair Pair; + using Pair = pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index c11d70fa..78bd3994 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -23,8 +23,8 @@ main() const int n = 12; - typedef adjacency_list > graph_t; + using graph_t = adjacency_list >; graph_t g1(n), g2(n); std::vector::vertex_descriptor> v1(n), v2(n); diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 059400b9..d77d4ed1 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -19,10 +19,10 @@ int main() { using namespace boost; - typedef adjacency_list > > Graph; + using Graph = adjacency_list > >; const int V = 6; - typedef std::pair < int, int >Edge; + using Edge = std::pair < int, int >; Edge edge_array[] = { Edge(0, 1), Edge(0, 2), Edge(0, 3), Edge(0, 4), Edge(0, 5), Edge(1, 2), Edge(1, 5), Edge(1, 3), Edge(2, 4), Edge(2, 5), diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 8d35b195..1da9617a 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -53,15 +53,15 @@ main() return EXIT_FAILURE; } - typedef adjacency_list < vecS, vecS, undirectedS, property < vertex_name_t, - std::string >, property < edge_name_t, std::string > > Graph; + using Graph = adjacency_list < vecS, vecS, undirectedS, property < vertex_name_t, + std::string >, property < edge_name_t, std::string > >; Graph g; auto actor_name = get(vertex_name, g); auto connecting_movie = get(edge_name, g); - typedef graph_traits < Graph >::vertex_descriptor Vertex; - typedef std::map < std::string, Vertex > NameVertexMap; + using Vertex = graph_traits < Graph >::vertex_descriptor; + using NameVertexMap = std::map < std::string, Vertex >; NameVertexMap actors; for (std::string line; std::getline(datafile, line);) { diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index 4532d25a..d6ce7814 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -38,10 +38,10 @@ struct edge_properties { using namespace boost; -typedef adjacency_list Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = adjacency_list; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; class bacon_number_recorder : public default_bfs_visitor { diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index daa68e33..0f31b05b 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -33,13 +33,13 @@ int main(int , char* []) { using namespace boost; using namespace std; - typedef adjacency_list > > Graph; - typedef graph_traits::vertex_descriptor Vertex; - typedef graph_traits::vertices_size_type size_type; + property > >; + using Vertex = graph_traits::vertex_descriptor; + using size_type = graph_traits::vertices_size_type; - typedef std::pair Pair; + using Pair = std::pair; Pair edges[14] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 048cbde4..e525d736 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -17,9 +17,7 @@ using namespace boost; -typedef -std::pair < int, int > - Position; +using Position = std::pair < int, int >; Position knight_jumps[8] = { Position(2, -1), @@ -92,35 +90,22 @@ struct knight_adjacency_iterator: struct knights_tour_graph { - typedef Position - vertex_descriptor; - typedef + using vertex_descriptor = Position; + using edge_descriptor = std::pair < vertex_descriptor, - vertex_descriptor > - edge_descriptor; - typedef knight_adjacency_iterator - adjacency_iterator; - typedef void - out_edge_iterator; - typedef void - in_edge_iterator; - typedef void - edge_iterator; - typedef void - vertex_iterator; - typedef int - degree_size_type; - typedef int - vertices_size_type; - typedef int - edges_size_type; - typedef directed_tag - directed_category; - typedef disallow_parallel_edge_tag - edge_parallel_category; - typedef adjacency_graph_tag - traversal_category; + vertex_descriptor >; + using adjacency_iterator = knight_adjacency_iterator; + using out_edge_iterator = void; + using in_edge_iterator = void; + using edge_iterator = void; + using vertex_iterator = void; + using degree_size_type = int; + using vertices_size_type = int; + using edges_size_type = int; + using directed_category = directed_tag; + using edge_parallel_category = disallow_parallel_edge_tag; + using traversal_category = adjacency_graph_tag; knights_tour_graph(int n): m_board_size(n) { @@ -152,7 +137,7 @@ std::pair < knights_tour_graph::adjacency_iterator, adjacent_vertices(knights_tour_graph::vertex_descriptor v, const knights_tour_graph & g) { - typedef knights_tour_graph::adjacency_iterator Iter; + using Iter = knights_tour_graph::adjacency_iterator; return std::make_pair(Iter(0, v, g), Iter(8, v, g)); } @@ -171,8 +156,8 @@ template < typename Graph, typename TimePropertyMap > Graph >::vertex_descriptor src, TimePropertyMap time_map) { - typedef typename graph_traits < Graph >::vertex_descriptor Vertex; - typedef std::pair < int, Vertex > P; + using Vertex = typename graph_traits < Graph >::vertex_descriptor; + using P = std::pair < int, Vertex >; std::stack < P > S; int time_stamp = 0; @@ -224,8 +209,8 @@ template < typename Graph, typename TimePropertyMap > typename graph_traits < Graph >::vertex_descriptor src, TimePropertyMap time_map) { - typedef typename graph_traits < Graph >::vertex_descriptor Vertex; - typedef std::pair < int, Vertex > P; + using Vertex = typename graph_traits < Graph >::vertex_descriptor; + using P = std::pair < int, Vertex >; std::stack < P > S; int time_stamp = 0; @@ -271,9 +256,9 @@ template < typename Graph, typename TimePropertyMap > struct board_map { - typedef int value_type; - typedef Position key_type; - typedef read_write_property_map_tag category; + using value_type = int; + using key_type = Position; + using category = read_write_property_map_tag; board_map(int *b, int n):m_board(b), m_size(n) { } diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 0307e9d2..b3b1bf44 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -14,10 +14,10 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, undirectedS, - no_property, property < edge_weight_t, int > > Graph; - typedef graph_traits < Graph >::edge_descriptor Edge; - typedef std::pair E; + using Graph = adjacency_list < vecS, vecS, undirectedS, + no_property, property < edge_weight_t, int > >; + using Edge = graph_traits < Graph >::edge_descriptor; + using E = std::pair; const int num_nodes = 5; E edge_array[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index a8eb4051..9fbf7a85 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -19,8 +19,8 @@ main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - typedef adjacency_list < vecS, vecS, undirectedS, no_property, - property < edge_weight_t, int > > Graph; + using Graph = adjacency_list < vecS, vecS, undirectedS, no_property, + property < edge_weight_t, int > >; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; @@ -31,7 +31,7 @@ main() } std::vector < graph_traits < Graph >::edge_descriptor > mst; - typedef std::vector < graph_traits < Graph >::edge_descriptor >::size_type size_type; + using size_type = std::vector < graph_traits < Graph >::edge_descriptor >::size_type; kruskal_minimum_spanning_tree(g, std::back_inserter(mst)); auto weight = get(edge_weight, g); @@ -40,7 +40,7 @@ main() total_weight += get(weight, edge); std::cout << "total weight: " << total_weight << std::endl; - typedef graph_traits < Graph >::vertex_descriptor Vertex; + using Vertex = graph_traits < Graph >::vertex_descriptor; for (const auto& edge : mst) { auto u = source(edge, g), v = target(edge, g); edge_attr_map[edge(u, v, g_dot).first]["color"] = "black"; diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index bf8447ac..b9185a2b 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -22,14 +22,13 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property, property - > - graph; + >; // Create a K_6 (complete graph on 6 vertices), which // contains both Kuratowski subgraphs as minors. @@ -61,8 +60,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is not planar, we just want to // compute the kuratowski subgraph as a side-effect - typedef std::vector< graph_traits::edge_descriptor > - kuratowski_edges_t; + using kuratowski_edges_t = std::vector< graph_traits::edge_descriptor >; kuratowski_edges_t kuratowski_edges; if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::kuratowski_subgraph = diff --git a/example/labeled_graph.cpp b/example/labeled_graph.cpp index fdcdd4b6..0cdd6f7f 100644 --- a/example/labeled_graph.cpp +++ b/example/labeled_graph.cpp @@ -17,10 +17,10 @@ int main() { using namespace boost::graph_detail; - typedef directed_graph<> Digraph; + using Digraph = directed_graph<>; { - typedef labeled_graph Graph; + using Graph = labeled_graph; Graph g; add_vertex(1, g); add_vertex(2, g); @@ -29,14 +29,14 @@ int main() { } { - typedef labeled_graph Graph; + using Graph = labeled_graph; Graph g; add_vertex("foo", g); add_vertex("bar", g); } { - typedef labeled_graph Graph; + using Graph = labeled_graph; Graph g; add_vertex("foo", g); add_vertex("bar", g); @@ -44,7 +44,7 @@ int main() { } { - typedef labeled_graph TempGraph; + using TempGraph = labeled_graph; Digraph g; TempGraph h(&g); add_vertex(12, h); @@ -53,8 +53,8 @@ int main() { { // This is actually a fairly complicated specialization. - typedef adjacency_list G; - typedef labeled_graph Graph; + using G = adjacency_list; + using Graph = labeled_graph; Graph g; add_vertex(0, g); add_vertex(1, g); diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index 4fcd1a1e..e5777bd7 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -19,7 +19,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -42,11 +42,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in("makefile-dependencies.dat"), @@ -63,15 +63,15 @@ main() // Create storage for last modified times std::vector < time_t > last_mod_vec(num_vertices(g)); // Create nickname for the property map type - typedef iterator_property_map < std::vector < time_t >::iterator, - property_map < graph_type, vertex_index_t >::type, time_t, time_t&> iter_map_t; + using iter_map_t = iterator_property_map < std::vector < time_t >::iterator, + property_map < graph_type, vertex_index_t >::type, time_t, time_t&>; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); auto name = get(vertex_name, g); struct stat stat_buf; graph_traits < graph_type >::vertex_descriptor u; - typedef graph_traits < graph_type >::vertex_iterator vertex_iter_t; + using vertex_iter_t = graph_traits < graph_type >::vertex_iterator; std::pair < vertex_iter_t, vertex_iter_t > p; for (p = vertices(g); p.first != p.second; ++p.first) { u = *p.first; diff --git a/example/leda-concept-check.cpp b/example/leda-concept-check.cpp index f5720e7d..39cf4f78 100644 --- a/example/leda-concept-check.cpp +++ b/example/leda-concept-check.cpp @@ -13,7 +13,7 @@ int main() { using namespace boost; - typedef leda::GRAPH Graph; + using Graph = leda::GRAPH; BOOST_CONCEPT_ASSERT(( VertexListGraphConcept )); BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept< Graph> )); BOOST_CONCEPT_ASSERT(( VertexMutableGraphConcept< Graph> )); diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index 3ca3a4f8..d9663563 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -12,14 +12,14 @@ int main() { using namespace boost; - typedef leda::GRAPH < std::string, int >graph_t; + using graph_t = leda::GRAPH < std::string, int >; graph_t g; g.new_node("Philoctetes"); g.new_node("Heracles"); g.new_node("Alcmena"); g.new_node("Eurystheus"); g.new_node("Amphitryon"); - typedef property_map < graph_t, vertex_all_t >::type NodeMap; + using NodeMap = property_map < graph_t, vertex_all_t >::type; auto node_name_map = get(vertex_all, g); graph_traits < graph_t >::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index de8f701f..3c9f345f 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -49,7 +49,7 @@ find_loops(typename graph_traits < Graph >::vertex_descriptor entry, Loops & loops) // A container of sets of vertices { BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); - typedef typename graph_traits < Graph >::edge_descriptor Edge; + using Edge = typename graph_traits < Graph >::edge_descriptor; std::vector < Edge > back_edges; std::vector < default_color_type > color_map(num_vertices(g)); depth_first_visit(g, entry, @@ -70,8 +70,8 @@ compute_loop_extent(typename graph_traits < Set & loop_set) { BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); - typedef typename graph_traits < Graph >::vertex_descriptor Vertex; - typedef color_traits < default_color_type > Color; + using Vertex = typename graph_traits < Graph >::vertex_descriptor; + using Color = color_traits < default_color_type >; Vertex loop_head, loop_tail; loop_tail = source(back_edge, g); @@ -108,10 +108,10 @@ main(int argc, char *argv[]) GraphvizDigraph g_in; read_graphviz(argv[1], g_in); - typedef adjacency_list < vecS, vecS, bidirectionalS, + using Graph = adjacency_list < vecS, vecS, bidirectionalS, GraphvizVertexProperty, - GraphvizEdgeProperty, GraphvizGraphProperty > Graph; - typedef graph_traits < Graph >::vertex_descriptor Vertex; + GraphvizEdgeProperty, GraphvizGraphProperty >; + using Vertex = graph_traits < Graph >::vertex_descriptor; Graph g; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -121,8 +121,8 @@ main(int argc, char *argv[]) copy_graph(g_in, g); - typedef std::set < Vertex > set_t; - typedef std::list < set_t > list_of_sets_t; + using set_t = std::set < Vertex >; + using list_of_sets_t = std::list < set_t >; list_of_sets_t loops; auto entry = *vertices(g).first; diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index f0c27e19..28a69264 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -23,14 +23,13 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property, property - > - graph; + >; graph g(11); add_edge(0,1,g); @@ -56,7 +55,7 @@ int main(int argc, char** argv) //Test for planarity; compute the planar embedding as a side-effect - typedef std::vector< graph_traits::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits::edge_descriptor >; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = @@ -67,13 +66,11 @@ int main(int argc, char** argv) else std::cout << "Input graph is not planar" << std::endl; - typedef std::vector< graph_traits::edges_size_type > - component_storage_t; - typedef iterator_property_map + using component_storage_t = std::vector< graph_traits::edges_size_type >; + using component_map_t = iterator_property_map < component_storage_t::iterator, property_map::type - > - component_map_t; + >; component_storage_t component_storage(num_edges(g)); component_map_t component(component_storage.begin(), get(edge_index, g)); diff --git a/example/make_connected.cpp b/example/make_connected.cpp index 91ceb9a7..4cd44c39 100644 --- a/example/make_connected.cpp +++ b/example/make_connected.cpp @@ -22,13 +22,12 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property - > - graph; + >; graph g(11); add_edge(0,1,g); diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index 86b6cfa8..58cc5fe9 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -43,14 +43,13 @@ struct face_counter : public planar_face_traversal_visitor int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property, property - > - graph; + >; // Create the graph - a straight line graph g(10); @@ -79,7 +78,7 @@ int main(int argc, char** argv) //Test for planarity; compute the planar embedding as a side-effect - typedef std::vector< graph_traits::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits::edge_descriptor >; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = diff --git a/example/matching_example.cpp b/example/matching_example.cpp index 5c6c26bf..c91901f5 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -16,7 +16,7 @@ using namespace boost; -typedef adjacency_list my_graph; +using my_graph = adjacency_list; int main() { diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 05249540..ad1fee84 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -49,13 +49,13 @@ main() { using namespace boost; - typedef adjacency_list_traits Traits; - typedef adjacency_list; + using Graph = adjacency_list, property > > - > Graph; + >; Graph g; diff --git a/example/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index d49d1424..bdfab55d 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -26,7 +26,7 @@ using namespace boost; template struct example_callback { - typedef typename graph_traits::vertices_size_type VertexSizeFirst; + using VertexSizeFirst = typename graph_traits::vertices_size_type; example_callback(const Graph& graph1) : m_graph1(graph1) { } @@ -38,8 +38,8 @@ struct example_callback { VertexSizeFirst subgraph_size) { // Fill membership map for first graph - typedef typename property_map::type VertexIndexMap; - typedef shared_array_property_map MembershipMap; + using VertexIndexMap = typename property_map::type; + using MembershipMap = shared_array_property_map; MembershipMap membership_map1(num_vertices(m_graph1), get(vertex_index, m_graph1)); @@ -47,8 +47,8 @@ struct example_callback { fill_membership_map(m_graph1, correspondence_map_1_to_2, membership_map1); // Generate filtered graphs using membership map - typedef typename membership_filtered_graph_traits::graph_type - MembershipFilteredGraph; + using MembershipFilteredGraph = + typename membership_filtered_graph_traits::graph_type; MembershipFilteredGraph subgraph1 = make_membership_filtered_graph(m_graph1, membership_map1); @@ -71,10 +71,10 @@ int main (int argc, char *argv[]) { // Using a vecS graph here so that we don't have to mess around with // a vertex index map; it will be implicit. - typedef adjacency_list >, - property > Graph; + property >; // Test maximum and unique variants on known graphs Graph graph_simple1, graph_simple2; diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index 55e3262a..fc98d0b2 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -24,29 +24,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map WeightMap; +using WeightMap = constant_property_map; // Declare a container and its corresponding property map that // will contain the resulting mean geodesic distances of each // vertex in the graph. -typedef exterior_vertex_property GeodesicProperty; -typedef GeodesicProperty::container_type GeodesicContainer; -typedef GeodesicProperty::map_type GeodesicMap; +using GeodesicProperty = exterior_vertex_property; +using GeodesicContainer = GeodesicProperty::container_type; +using GeodesicMap = GeodesicProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/miles_span.cpp b/example/miles_span.cpp index 81ca43c1..11d7d40a 100644 --- a/example/miles_span.cpp +++ b/example/miles_span.cpp @@ -24,7 +24,7 @@ // PropertyMap. template struct total_length_visitor : public boost::dijkstra_visitor<> { - typedef typename boost::property_traits::value_type D; + using D = typename boost::property_traits::value_type; total_length_visitor(D& len, Distance d) : _total_length(len), _distance(d) { } template diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index 7c53394f..a20d84a6 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -42,11 +42,11 @@ main(int , char* []) { using namespace boost; - typedef adjacency_list > Graph; - typedef graph_traits::vertex_descriptor Vertex; + using Graph = adjacency_list >; + using Vertex = graph_traits::vertex_descriptor; - typedef std::pair E; + using E = std::pair; const char name[] = "abcdef"; diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index cc3ca770..b8e786fe 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -98,11 +98,11 @@ int main(int argc, char* argv[]) if ( argc >= 4 ) delta = atoi(argv[3]); - + harwell_boeing hbs(argv[1]); //must be BGL directed graph now - typedef adjacency_list Graph; + using Graph = adjacency_list ; int n = hbs.nrows(); @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) cout << "number of off-diagnal elements: " << num_edge << endl; - typedef std::vector Vector; + using Vector = std::vector; Vector inverse_perm(n, 0); Vector perm(n, 0); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 358c69a6..19a98d77 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -39,9 +39,9 @@ name_equals(const std::string& str, NamePropertyMap name) { template void modify_demo(MutableGraph& g) { - typedef graph_traits GraphTraits; - typedef typename GraphTraits::vertices_size_type size_type; - typedef typename GraphTraits::edge_descriptor edge_descriptor; + using GraphTraits = graph_traits; + using size_type = typename GraphTraits::vertices_size_type; + using edge_descriptor = typename GraphTraits::edge_descriptor; size_type n = 0; typename GraphTraits::edges_size_type m = 0; typename GraphTraits::vertex_descriptor u, v, w; diff --git a/example/neighbor_bfs.cpp b/example/neighbor_bfs.cpp index a70e33c2..e4b4ea21 100644 --- a/example/neighbor_bfs.cpp +++ b/example/neighbor_bfs.cpp @@ -53,8 +53,8 @@ struct print_parent { template class distance_and_pred_visitor : public neighbor_bfs_visitor<> { - typedef typename property_traits::value_type ColorValue; - typedef color_traits Color; + using ColorValue = typename property_traits::value_type; + using Color = color_traits; public: distance_and_pred_visitor(DistanceMap d, PredecessorMap p, ColorMap c) : m_distance(d), m_predecessor(p), m_color(c) { } @@ -81,13 +81,12 @@ class distance_and_pred_visitor : public neighbor_bfs_visitor<> int main(int , char* []) { - typedef adjacency_list< + using Graph = adjacency_list< mapS, vecS, bidirectionalS, property - > Graph; + >; - typedef property_map::type - ColorMap; + using ColorMap = property_map::type; Graph G(5); add_edge(0, 2, G); @@ -102,19 +101,19 @@ int main(int , char* []) add_edge(4, 0, G); add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; // Array to store predecessor (parent) of each vertex. This will be // used as a Decorator (actually, its iterator will be). std::vector p(num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector::value_type* Piter; + using Piter = std::vector::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as // a Decorator. - typedef graph_traits::vertices_size_type size_type; + using size_type = graph_traits::vertices_size_type; size_type d[5]; std::fill_n(d, 5, 0); diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 8cbc40a4..e577c01d 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -48,17 +48,17 @@ struct ordered_set_by_nameS { }; namespace boost { template struct container_gen { - typedef std::multiset > type; + using type = std::multiset >; }; } #else struct ordered_set_by_nameS { template - struct bind_ { typedef std::multiset > type; }; + struct bind_ { using } = std::multiset > type;; }; namespace boost { template <> struct container_selector { - typedef ordered_set_by_nameS type; + using type = ordered_set_by_nameS; }; } #endif @@ -66,7 +66,7 @@ namespace boost { namespace boost { template <> struct parallel_edge_traits { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; } @@ -77,9 +77,9 @@ main() std::cout << "This program requires partial specialization" << std::endl; #else using namespace boost; - typedef property EdgeProperty; - typedef adjacency_list graph_type; + using EdgeProperty = property; + using graph_type = adjacency_list; graph_type g; add_edge(0, 1, EdgeProperty("joe"), g); @@ -104,7 +104,7 @@ main() std::cout << std::endl; bool found; - typedef graph_traits Traits; + using Traits = graph_traits; Traits::edge_descriptor e; Traits::out_edge_iterator e_first, e_last; diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index e4647527..ed7109ea 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -19,13 +19,12 @@ int main() { using namespace boost; - typedef + using g_dot_type = adjacency_list, property >, - property > - g_dot_type; + property >; g_dot_type g_dot; dynamic_properties dp(ignore_other_properties); @@ -38,9 +37,9 @@ main() read_graphviz(infile, g_dot, dp); } - typedef adjacency_list < vecS, vecS, directedS, no_property, - property < edge_weight_t, int > > Graph; - typedef graph_traits < Graph >::vertex_descriptor vertex_descriptor; + using Graph = adjacency_list < vecS, vecS, directedS, no_property, + property < edge_weight_t, int > >; + using vertex_descriptor = graph_traits < Graph >::vertex_descriptor; Graph g(num_vertices(g_dot)); graph_traits < g_dot_type >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { @@ -59,7 +58,7 @@ main() std::vector < vertex_descriptor > parent(num_vertices(g)); // All vertices start out as there own parent - typedef graph_traits < Graph >::vertices_size_type size_type; + using size_type = graph_traits < Graph >::vertices_size_type; for (size_type p = 0; p < num_vertices(g); ++p) parent[p] = p; diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 970dac1e..ca8af7e7 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -33,7 +33,7 @@ namespace boost using namespace boost; -typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph2 = adjacency_list < listS, // Store out-edges of each vertex in a std::list listS, // Store vertex set in a std::list directedS, // The file dependency graph is directed // vertex properties @@ -42,11 +42,10 @@ typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list property < vertex_distance_t, float, property < vertex_color_t, default_color_type > > > >, // an edge property - property < edge_weight_t, float > > - file_dep_graph2; + property < edge_weight_t, float > >; -typedef graph_traits::vertex_descriptor vertex_t; -typedef graph_traits::edge_descriptor edge_t; +using vertex_t = graph_traits::vertex_descriptor; +using edge_t = graph_traits::edge_descriptor; template < typename Graph, typename ColorMap, typename Visitor > void @@ -54,8 +53,8 @@ dfs_v2(const Graph & g, typename graph_traits < Graph >::vertex_descriptor u, ColorMap color, Visitor vis) { - typedef typename property_traits < ColorMap >::value_type color_type; - typedef color_traits < color_type > ColorT; + using color_type = typename property_traits < ColorMap >::value_type; + using ColorT = color_traits < color_type >; color[u] = ColorT::gray(); vis.discover_vertex(u, g); typename graph_traits < Graph >::out_edge_iterator ei, ei_end; @@ -74,8 +73,8 @@ dfs_v2(const Graph & g, template < typename Graph, typename Visitor, typename ColorMap > void generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) { - typedef typename property_traits ::value_type ColorValue; - typedef color_traits < ColorValue > ColorT; + using ColorValue = typename property_traits ::value_type; + using ColorT = color_traits < ColorValue > ; typename graph_traits < Graph >::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) color[*vi] = ColorT::white(); @@ -109,18 +108,17 @@ topo_sort(const Graph & g, OutputIterator topo_order, ColorMap color) } -typedef property_map < file_dep_graph2, vertex_name_t >::type name_map_t; -typedef property_map < file_dep_graph2, vertex_compile_cost_t >::type - compile_cost_map_t; -typedef property_map < file_dep_graph2, vertex_distance_t >::type distance_map_t; -typedef property_map < file_dep_graph2, vertex_color_t >::type color_map_t; +using name_map_t = property_map < file_dep_graph2, vertex_name_t >::type; +using compile_cost_map_t = property_map < file_dep_graph2, vertex_compile_cost_t >::type; +using distance_map_t = property_map < file_dep_graph2, vertex_distance_t >::type; +using color_map_t = property_map < file_dep_graph2, vertex_color_t >::type; int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits < file_dep_graph2 >::vertices_size_type size_type; + using size_type = graph_traits < file_dep_graph2 >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, @@ -128,7 +126,7 @@ main() #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor file_dep_graph2 g; - typedef graph_traits::vertex_descriptor vertex_t; + using vertex_t = graph_traits::vertex_descriptor; std::vector id2vertex; for (std::size_t v = 0; v < n_vertices; ++v) id2vertex.emplace_back(add_vertex(g)); diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index c24a07dc..9df040a5 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -56,14 +56,13 @@ struct edge_output_visitor : public output_visitor int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property, property - > - graph; + >; // Create a graph - this is a biconnected, 3 x 3 grid. // It should have four small (four vertex/four edge) faces and @@ -100,7 +99,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - typedef std::vector< graph_traits::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits::edge_descriptor >; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = diff --git a/example/prim-example.cpp b/example/prim-example.cpp index 3d1dbf39..49607a97 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -14,9 +14,9 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, undirectedS, - property, property < edge_weight_t, int > > Graph; - typedef std::pair < int, int >E; + using Graph = adjacency_list < vecS, vecS, undirectedS, + property, property < edge_weight_t, int > >; + using E = std::pair < int, int>; const int num_nodes = 5; E edges[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 69d21983..a870adac 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -19,8 +19,8 @@ main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - typedef adjacency_list < vecS, vecS, undirectedS, no_property, - property < edge_weight_t, int > > Graph; + using Graph = adjacency_list < vecS, vecS, undirectedS, no_property, + property < edge_weight_t, int > >; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; @@ -30,7 +30,7 @@ main() add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } - typedef graph_traits < Graph >::vertex_descriptor Vertex; + using Vertex = graph_traits < Graph >::vertex_descriptor; std::vector < Vertex > parent(num_vertices(g)); auto weight = get(edge_weight, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 6c20941d..d9e5b920 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -75,11 +75,11 @@ name_equals(const std::string & str, NameMap name) int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 7616022b..13129a1d 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -50,11 +50,11 @@ print_dependencies(std::ostream & out, const Graph & g, int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index 3a889f06..d326bc36 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -74,11 +74,11 @@ name_equals(const std::string & str, NameMap name) int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector bidirectionalS, // The graph is directed, with both out-edges and in-edges property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index 7e3cbef6..68d23d09 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -74,11 +74,11 @@ name_equals(const std::string & str, NameMap name) int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; @@ -101,7 +101,7 @@ main() graph_traits < graph_type >::vertex_iterator i, end; boost::tie(i, end) = vertices(g); - typedef property_map < graph_type, vertex_name_t >::type name_map_t; + using name_map_t = property_map < graph_type, vertex_name_t >::type; name_equals_t < name_map_t > predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); output_out_edges(std::cout, g, *i, get(vertex_name, g)); diff --git a/example/property-map-traits-eg.cpp b/example/property-map-traits-eg.cpp index c136e82e..d0664042 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -13,8 +13,8 @@ int main() { using namespace boost; - typedef adjacency_list < listS, listS, directedS, - property < vertex_name_t, std::string > >graph_t; + using graph_t = adjacency_list < listS, listS, directedS, + property < vertex_name_t, std::string > >; graph_t g; graph_traits < graph_t >::vertex_descriptor u = add_vertex(g); auto name_map = get(vertex_name, g); diff --git a/example/property_iterator.cpp b/example/property_iterator.cpp index 6a5a1348..8ba2d306 100644 --- a/example/property_iterator.cpp +++ b/example/property_iterator.cpp @@ -22,37 +22,37 @@ using namespace boost; //======== vertex properties struct toto_t { enum { num = 23063}; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< toto_t, double > Toto; +using Toto = property< toto_t, double >; struct radius_t { enum { num = 23062}; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< radius_t, double, Toto > Radius; +using Radius = property< radius_t, double, Toto >; struct mass_t { enum { num = 23061}; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< mass_t, int, Radius > Mass; +using Mass = property< mass_t, int, Radius >; //====== edge properties struct stiff_t { enum { num = 23064}; - typedef edge_property_tag kind; + using kind = edge_property_tag; }; -typedef property Stiff; +using Stiff = property; //===== graph type -typedef Mass VertexProperty; -typedef Stiff EdgeProperty; -typedef adjacency_list Graph; +using VertexProperty = Mass; +using EdgeProperty = Stiff; +using Graph = adjacency_list; //===== utilities diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index 6c92bca4..c8a955e2 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -46,12 +46,12 @@ int main() { using namespace boost; - typedef adjacency_list_traits < vecS, vecS, directedS > Traits; - typedef adjacency_list < vecS, vecS, directedS, + using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Graph = adjacency_list < vecS, vecS, directedS, property < vertex_name_t, std::string >, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; + property < edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; auto capacity = get(edge_capacity, g); diff --git a/example/put-get-helper-eg.cpp b/example/put-get-helper-eg.cpp index 9c14e1b9..fef57a5e 100644 --- a/example/put-get-helper-eg.cpp +++ b/example/put-get-helper-eg.cpp @@ -24,12 +24,10 @@ namespace foo iterator_property_map < RandomAccessIterator, IndexMap > > { public: - typedef std::ptrdiff_t key_type; - typedef typename std::iterator_traits < RandomAccessIterator >::value_type - value_type; - typedef typename std::iterator_traits < RandomAccessIterator >::reference - reference; - typedef boost::lvalue_property_map_tag category; + using key_type = std::ptrdiff_t; + using value_type = typename std::iterator_traits < RandomAccessIterator >::value_type; + using reference = typename std::iterator_traits < RandomAccessIterator >::reference; + using category = boost::lvalue_property_map_tag; iterator_property_map(RandomAccessIterator cc = RandomAccessIterator(), const IndexMap & _id = @@ -50,9 +48,9 @@ namespace foo int main() { - typedef std::vector < std::string > vec_t; - typedef foo::iterator_property_map < vec_t::iterator, - boost::identity_property_map > pmap_t; + using vec_t = std::vector < std::string >; + using pmap_t = foo::iterator_property_map < vec_t::iterator, + boost::identity_property_map >; using namespace boost; BOOST_CONCEPT_ASSERT(( Mutable_LvaluePropertyMapConcept )); return 0; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 396fceab..0516ba8a 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -32,7 +32,7 @@ template < typename Graph, typename VertexNameMap > void print_vertex_names(const Graph & g, VertexNameMap name_map) { std::cout << "vertices(g) = { "; - typedef typename graph_traits < Graph >::vertex_iterator iter_t; + using iter_t = typename graph_traits < Graph >::vertex_iterator; for (auto p = vertices(g); p.first != p.second; ++p.first) { print_vertex_name(*p.first, name_map); @@ -92,9 +92,9 @@ build_router_network(Graph & g, VertexNameMap name_map, int main() { - typedef adjacency_list < listS, listS, directedS, + using graph_t = adjacency_list < listS, listS, directedS, property < vertex_name_t, char >, - property < edge_weight_t, double > > graph_t; + property < edge_weight_t, double > >; graph_t g; auto name_map = get(vertex_name, g); diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 34644fc3..b126ea1a 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -19,7 +19,7 @@ using namespace boost; template struct exercise_vertex { exercise_vertex(Graph& g_, const char name_[]) : g(g_),name(name_) { } - typedef typename graph_traits::vertex_descriptor Vertex; + using Vertex = typename graph_traits::vertex_descriptor; void operator()(const Vertex& v) const { using namespace boost; @@ -66,9 +66,9 @@ template struct exercise_vertex { int main(int,char*[]) { - // create a typedef for the Graph type - typedef adjacency_list > Graph; + // create an alias for the Graph type + using Graph = adjacency_list >; // Make convenient labels for the vertices enum { A, B, C, D, E, N }; @@ -76,7 +76,7 @@ int main(int,char*[]) const char name[] = "ABCDE"; // writing out the edges in the graph - typedef std::pair Edge; + using Edge = std::pair; Edge edge_array[] = { Edge(A,B), Edge(A,D), Edge(C,A), Edge(D,C), Edge(C,E), Edge(B,D), Edge(D,E), }; @@ -106,7 +106,7 @@ int main(int,char*[]) trans_delay = get(edge_weight, g); std::cout << "vertices(g) = "; - typedef graph_traits::vertex_iterator vertex_iter; + using vertex_iter = graph_traits::vertex_iterator; std::pair vp; for (vp = vertices(g); vp.first != vp.second; ++vp.first) std::cout << name[get(vertex_id, *vp.first)] << " "; diff --git a/example/r_c_shortest_paths_example.cpp b/example/r_c_shortest_paths_example.cpp index 518b90c6..89413da5 100644 --- a/example/r_c_shortest_paths_example.cpp +++ b/example/r_c_shortest_paths_example.cpp @@ -39,12 +39,11 @@ struct SPPRC_Example_Graph_Arc_Prop int time; }; -typedef adjacency_list - SPPRC_Example_Graph; + SPPRC_Example_Graph_Arc_Prop>; // data structures for spp without resource constraints: // ResourceContainer model diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index e295571d..64181a91 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -25,7 +25,7 @@ main(int argc, char *argv[]) GraphvizDigraph g; read_graphviz(argv[1], g); graph_traits < GraphvizDigraph >::vertex_descriptor loop_head = 1; - typedef color_traits < default_color_type > Color; + using Color = color_traits < default_color_type >; std::vector < default_color_type > reachable_from_head(num_vertices(g), Color::white()); diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index 8e4e3efe..58da2d9c 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -26,14 +26,14 @@ main(int argc, char *argv[]) GraphvizDigraph g_in; read_graphviz(argv[1], g_in); - typedef adjacency_list < vecS, vecS, bidirectionalS, + using Graph = adjacency_list < vecS, vecS, bidirectionalS, GraphvizVertexProperty, - GraphvizEdgeProperty, GraphvizGraphProperty > Graph; + GraphvizEdgeProperty, GraphvizGraphProperty >; Graph g; copy_graph(g_in, g); graph_traits < GraphvizDigraph >::vertex_descriptor loop_tail = 6; - typedef color_traits < default_color_type > Color; + using Color = color_traits < default_color_type >; default_color_type c; std::vector < default_color_type > reachable_to_tail(num_vertices(g)); diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index a371e0a5..c1521722 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -20,15 +20,15 @@ using namespace std; int main() { // Vertex properties - typedef property < vertex_name_t, std::string, - property < vertex_color_t, float > > vertex_p; + using vertex_p = property < vertex_name_t, std::string, + property < vertex_color_t, float > >; // Edge properties - typedef property < edge_weight_t, double > edge_p; + using edge_p = property < edge_weight_t, double >; // Graph properties - typedef property < graph_name_t, std::string > graph_p; + using graph_p = property < graph_name_t, std::string >; // adjacency_list-based type - typedef adjacency_list < vecS, vecS, directedS, - vertex_p, edge_p, graph_p > graph_t; + using graph_t = adjacency_list < vecS, vecS, directedS, + vertex_p, edge_p, graph_p >; // Construct an empty graph and prepare the dynamic_property_maps. graph_t graph(0); diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index dd653814..062bb823 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -61,20 +61,20 @@ struct zero_edge_capacity{ int main() { using namespace boost; - typedef adjacency_list_traits < vecS, vecS, directedS > Traits; - typedef adjacency_list < vecS, vecS, directedS, - no_property, - property < edge_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > Graph; + using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Graph = adjacency_list < vecS, vecS, directedS, + no_property, + property < edge_capacity_t, long, + property < edge_reverse_t, Traits::edge_descriptor > > >; - typedef graph_traits::out_edge_iterator out_edge_iterator; - typedef graph_traits::edge_descriptor edge_descriptor; - typedef graph_traits::vertex_descriptor vertex_descriptor; + using out_edge_iterator = graph_traits::out_edge_iterator; + using edge_descriptor = graph_traits::edge_descriptor; + using vertex_descriptor = graph_traits::vertex_descriptor; Graph g; - typedef property_map < Graph, edge_capacity_t >::type tCapMap; - typedef tCapMap::value_type tCapMapValue; + using tCapMap = property_map < Graph, edge_capacity_t >::type; + using tCapMapValue = tCapMap::value_type; auto capacity = get(edge_capacity, g); auto rev = get(edge_reverse, g); diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 4b40435d..b7350cd8 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -40,8 +40,8 @@ using namespace boost; -typedef adjacency_list > Graph; +using Graph = adjacency_list >; struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } @@ -61,7 +61,7 @@ struct has_weight_greater_than { int main() { - typedef std::pair Edge; + using Edge = std::pair; Edge edge_array[6] = { Edge(0,3), Edge(0,2), Edge(0, 3), Edge(1,3), Edge(2, 0), diff --git a/example/remove_edge_if_dir.cpp b/example/remove_edge_if_dir.cpp index 6b6f76ed..c44acf78 100644 --- a/example/remove_edge_if_dir.cpp +++ b/example/remove_edge_if_dir.cpp @@ -36,13 +36,13 @@ using namespace boost; -typedef adjacency_list Graph; +using Graph = adjacency_list; int main() { - typedef std::pair Edge; + using Edge = std::pair; Edge edges[6] = { Edge(0,3), Edge(0,2), Edge(0, 3), Edge(1,3), Edge(2, 0), diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index cfd13fdf..8fefca65 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -39,8 +39,8 @@ using namespace boost; */ -typedef adjacency_list > Graph; +using Graph = adjacency_list >; struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } @@ -60,7 +60,7 @@ struct has_weight_greater_than { int main() { - typedef std::pair Edge; + using Edge = std::pair; Edge edge_array[5] = { Edge(0, 3), Edge(0, 3), Edge(1, 3), Edge(2, 0), diff --git a/example/reverse_graph.cpp b/example/reverse_graph.cpp index 9ccf1875..2c7aacf6 100644 --- a/example/reverse_graph.cpp +++ b/example/reverse_graph.cpp @@ -20,7 +20,7 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, bidirectionalS > Graph; + using Graph = adjacency_list < vecS, vecS, bidirectionalS >; Graph G(5); add_edge(0, 2, G); diff --git a/example/roget_components.cpp b/example/roget_components.cpp index d22eb6cf..1a576cf0 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) { using namespace boost; Graph* g; - typedef graph_traits::vertex_descriptor vertex_t; + using vertex_t = graph_traits::vertex_descriptor; unsigned long n = 0; unsigned long d = 0; unsigned long p = 0; diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index a2ade80c..4099004b 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -29,8 +29,8 @@ template > struct scaled_closeness_measure { - typedef Distance distance_type; - typedef Result result_type; + using distance_type = Distance; + using result_type = Result; Result operator ()(Distance d, const Graph& g) { @@ -51,29 +51,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = undirected_graph; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map::type NameMap; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map WeightMap; +using WeightMap = constant_property_map; // Declare a container and its corresponding property map that // will contain the resulting closeness centralities of each // vertex in the graph. -typedef boost::exterior_vertex_property ClosenessProperty; -typedef ClosenessProperty::container_type ClosenessContainer; -typedef ClosenessProperty::map_type ClosenessMap; +using ClosenessProperty = boost::exterior_vertex_property; +using ClosenessContainer = ClosenessProperty::container_type; +using ClosenessMap = ClosenessProperty::map_type; int main(int argc, char *argv[]) diff --git a/example/scc.cpp b/example/scc.cpp index 902b024a..97e45053 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -19,7 +19,7 @@ main() GraphvizDigraph g; read_graphviz("figs/scc.dot", g); - typedef graph_traits < GraphvizDigraph >::vertex_descriptor vertex_t; + using vertex_t = graph_traits < GraphvizDigraph >::vertex_descriptor; std::map < vertex_t, int >component; strong_components(g, make_assoc_property_map(component)); diff --git a/example/simple_planarity_test.cpp b/example/simple_planarity_test.cpp index 525c6701..c2f2f89d 100644 --- a/example/simple_planarity_test.cpp +++ b/example/simple_planarity_test.cpp @@ -18,11 +18,11 @@ int main(int argc, char** argv) using namespace boost; - typedef adjacency_list - > graph; + >; graph K_4(4); add_edge(0, 1, K_4); diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index 19b45198..f42b8ec3 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -73,7 +73,7 @@ int main(int , char* []) //Defining the graph type - typedef adjacency_list< + using Graph = adjacency_list< setS, vecS, undirectedS, @@ -85,12 +85,12 @@ int main(int , char* []) int, property< vertex_priority_t, - double > > > > Graph; + double > > > >; - typedef graph_traits::vertex_descriptor Vertex; - typedef graph_traits::vertices_size_type size_type; + using Vertex = graph_traits::vertex_descriptor; + using size_type = graph_traits::vertices_size_type; - typedef std::pair Pair; + using Pair = std::pair; Pair edges[14] = { Pair(0,3), //a-d Pair(0,5), //a-f diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index 09f13006..1a39764e 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -25,10 +25,10 @@ int main() { using namespace std; - typedef boost::adjacency_list > undirected_graph; - typedef boost::property_map::type weight_map_type; - typedef boost::property_traits::value_type weight_type; + using undirected_graph = boost::adjacency_list >; + using weight_map_type = boost::property_map::type; + using weight_type = boost::property_traits::value_type; // define the 16 edges of the graph. {3, 4} means an undirected edge between vertices 3 and 4. edge_t edges[] = {{3, 4}, {3, 6}, {3, 5}, {0, 4}, {0, 1}, {0, 6}, {0, 7}, diff --git a/example/straight_line_drawing.cpp b/example/straight_line_drawing.cpp index 15aa8296..9c499055 100644 --- a/example/straight_line_drawing.cpp +++ b/example/straight_line_drawing.cpp @@ -31,23 +31,21 @@ struct coord_t int main(int argc, char** argv) { - typedef adjacency_list + using graph = adjacency_list < vecS, vecS, undirectedS, property - > graph; + >; //Define the storage type for the planar embedding - typedef std::vector< std::vector< graph_traits::edge_descriptor > > - embedding_storage_t; - typedef boost::iterator_property_map + using embedding_storage_t = std::vector< std::vector< graph_traits::edge_descriptor > >; + using embedding_t = boost::iterator_property_map < embedding_storage_t::iterator, property_map::type - > - embedding_t; + >; @@ -94,12 +92,11 @@ int main(int argc, char** argv) //Set up a property map to hold the mapping from vertices to coord_t's - typedef std::vector< coord_t > straight_line_drawing_storage_t; - typedef boost::iterator_property_map + using straight_line_drawing_storage_t = std::vector< coord_t >; + using straight_line_drawing_t = boost::iterator_property_map < straight_line_drawing_storage_t::iterator, property_map::type - > - straight_line_drawing_t; + >; straight_line_drawing_storage_t straight_line_drawing_storage (num_vertices(g)); diff --git a/example/strong-components.cpp b/example/strong-components.cpp index f463f6bd..c9e50baa 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -15,7 +15,7 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, directedS > Graph; + using Graph = adjacency_list < vecS, vecS, directedS >; const int N = 6; Graph G(N); add_edge(0, 1, G); diff --git a/example/strong_components.cpp b/example/strong_components.cpp index 089e3ef9..a6c61b86 100644 --- a/example/strong_components.cpp +++ b/example/strong_components.cpp @@ -54,7 +54,7 @@ int main(int, char*[]) print_graph(G, name); std::cout << std::endl; - typedef graph_traits >::vertex_descriptor Vertex; + using Vertex = graph_traits >::vertex_descriptor; std::vector component(num_vertices(G)), discover_time(num_vertices(G)); std::vector color(num_vertices(G)); diff --git a/example/subgraph.cpp b/example/subgraph.cpp index 289ae54d..aeb89d78 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -41,8 +41,8 @@ int main(int,char*[]) { using namespace boost; - typedef subgraph< adjacency_list, property > > Graph; + using Graph = subgraph< adjacency_list, property > >; const int N = 6; Graph G0(N); diff --git a/example/subgraph_properties.cpp b/example/subgraph_properties.cpp index 2f222613..b9e70e18 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -38,12 +38,12 @@ int main(int,char*[]) { using namespace boost; - //typedef adjacency_list_traits Traits;// Does nothing? - typedef property< vertex_color_t, int, - property< vertex_name_t, std::string > > VertexProperty; + //using Traits = adjacency_list_traits;// Does nothing? + using VertexProperty = property< vertex_color_t, int, + property< vertex_name_t, std::string > >; - typedef subgraph< adjacency_list< vecS, vecS, directedS, - VertexProperty, property > > Graph; + using Graph = subgraph< adjacency_list< vecS, vecS, directedS, + VertexProperty, property > >; const int N = 6; Graph G0(N); diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index a277a3fd..93bd13e8 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -16,9 +16,9 @@ using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. -typedef directed_graph<> Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = directed_graph<>; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; int main(int argc, char *argv[]) diff --git a/example/tiernan_print_cycles.cpp b/example/tiernan_print_cycles.cpp index 75d804c8..2909b59c 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -44,9 +44,9 @@ struct cycle_printer }; // Declare the graph type and its vertex and edge types. -typedef directed_graph<> Graph; -typedef graph_traits::vertex_descriptor Vertex; -typedef graph_traits::edge_descriptor Edge; +using Graph = directed_graph<>; +using Vertex = graph_traits::vertex_descriptor; +using Edge = graph_traits::edge_descriptor; int main(int argc, char *argv[]) diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 98cca5f0..98d61631 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -24,13 +24,13 @@ namespace std } } -typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The file dependency graph is directed -> file_dep_graph; +>; -typedef graph_traits < file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits < file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits < file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits < file_dep_graph >::edge_descriptor; void topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, @@ -60,7 +60,7 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits < file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits < file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, size_type > > diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 5d9f2098..6ab226d9 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -26,14 +26,14 @@ namespace std } } -typedef adjacency_list < +using file_dep_graph = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS // The file dependency graph is directed - > file_dep_graph; + >; -typedef graph_traits ::vertex_descriptor vertex_t; -typedef graph_traits ::edge_descriptor edge_t; +using vertex_t = graph_traits ::vertex_descriptor; +using edge_t = graph_traits ::edge_descriptor; template < typename Visitor > void dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, @@ -119,7 +119,7 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef graph_traits::vertices_size_type size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, diff --git a/example/topo-sort-with-leda.cpp b/example/topo-sort-with-leda.cpp index 18a3b4ac..7cc4cd59 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -17,9 +17,9 @@ int main() { using namespace boost; - typedef GRAPH < std::string, char >graph_t; + using graph_t = GRAPH < std::string, char >; graph_t leda_g; - typedef graph_traits < graph_t >::vertex_descriptor vertex_t; + using vertex_t = graph_traits < graph_t >::vertex_descriptor; std::vector < vertex_t > vert(7); vert[0] = add_vertex(std::string("pick up kids from school"), leda_g); vert[1] = add_vertex(std::string("buy groceries (and snacks)"), leda_g); diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index cd343dfd..30d7941d 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -37,7 +37,7 @@ main() gb_new_arc(sgb_g->vertices + 4, sgb_g->vertices + 6, 0); gb_new_arc(sgb_g->vertices + 5, sgb_g->vertices + 6, 0); - typedef graph_traits < Graph * >::vertex_descriptor vertex_t; + using vertex_t = graph_traits < Graph * >::vertex_descriptor; std::vector < vertex_t > topo_order; topological_sort(sgb_g, std::back_inserter(topo_order), vertex_index_map(get(vertex_index, sgb_g))); diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index a0a6afb7..f66d9af6 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -16,7 +16,7 @@ #include -typedef std::pair Pair; +using Pair = std::pair; /* Topological sort example @@ -40,10 +40,10 @@ main(int , char* []) /* Topological sort will need to color the graph. Here we use an internal decorator, so we "property" the color to the graph. */ - typedef adjacency_list > Graph; + using Graph = adjacency_list >; - typedef boost::graph_traits::vertex_descriptor Vertex; + using Vertex = boost::graph_traits::vertex_descriptor; Pair edges[6] = { Pair(0,1), Pair(2,4), Pair(2,5), Pair(0,3), Pair(1,4), @@ -59,7 +59,7 @@ main(int , char* []) auto id = get(vertex_index, G); - typedef std::vector< Vertex > container; + using container = std::vector< Vertex >; container c; topological_sort(G, std::back_inserter(c)); diff --git a/example/transitive_closure.cpp b/example/transitive_closure.cpp index 2b99cdb9..8646ec84 100644 --- a/example/transitive_closure.cpp +++ b/example/transitive_closure.cpp @@ -18,10 +18,10 @@ int main(int, char *[]) { using namespace boost; - typedef property < vertex_name_t, char >Name; - typedef property < vertex_index_t, std::size_t, Name > Index; - typedef adjacency_list < listS, listS, directedS, Index > graph_t; - typedef graph_traits < graph_t >::vertex_descriptor vertex_t; + using Name = property < vertex_name_t, char >; + using Index = property < vertex_index_t, std::size_t, Name >; + using graph_t = adjacency_list < listS, listS, directedS, Index >; + using vertex_t = graph_traits < graph_t >::vertex_descriptor; graph_t G; std::vector < vertex_t > verts(4); for (int i = 0; i < 4; ++i) diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index fcd9dedf..28a8eeeb 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -15,8 +15,8 @@ int main() { using namespace boost; - typedef adjacency_list < vecS, vecS, bidirectionalS, - property < vertex_name_t, char > > graph_t; + using graph_t = adjacency_list < vecS, vecS, bidirectionalS, + property < vertex_name_t, char > >; enum { a, b, c, d, e, f, g, N }; graph_t G(N); @@ -26,7 +26,7 @@ main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair < int, int >E; + using E = std::pair < int, int >; E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index 9e05fcc2..baaa4a6f 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -17,7 +17,7 @@ using namespace std; -typedef +using Graph = boost::adjacency_list < boost::vecS, // OutEdgeList @@ -27,25 +27,19 @@ boost::adjacency_list boost::no_property, // EdgeProperties boost::no_property, // GraphProperties boost::listS // EdgeList - > -Graph -; + >; -typedef -boost::graph_traits::vertex_descriptor -vertex_descriptor; +using vertex_descriptor = +boost::graph_traits::vertex_descriptor; -typedef -boost::graph_traits::edge_descriptor -edge_descriptor; +using edge_descriptor = +boost::graph_traits::edge_descriptor; -typedef -boost::graph_traits::vertex_iterator -vertex_iterator; +using vertex_iterator = +boost::graph_traits::vertex_iterator; -typedef -boost::graph_traits::edge_iterator -edge_iterator; +using edge_iterator = +boost::graph_traits::edge_iterator; int main(int argc, char **argv) diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 2d4ee51d..f82f71b7 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -39,7 +39,7 @@ directed_graph_demo() { const int V = 2; DirectedGraph digraph(V); - typedef typename DirectedGraph::edge_property_type Weight; + using Weight = typename DirectedGraph::edge_property_type; auto weight = get(edge_weight, digraph); typename graph_traits < DirectedGraph >::edge_descriptor e1, e2; bool found; @@ -67,7 +67,7 @@ undirected_graph_demo2() { const int V = 2; UndirectedGraph undigraph(V); - typedef typename UndirectedGraph::edge_property_type Weight; + using Weight = typename UndirectedGraph::edge_property_type; typename property_map < UndirectedGraph, edge_weight_t >::type weight = get(edge_weight, undigraph); typename graph_traits < UndirectedGraph >::edge_descriptor e1, e2; @@ -100,11 +100,11 @@ undirected_graph_demo2() int main() { - typedef property < edge_weight_t, double >Weight; - typedef adjacency_list < vecS, vecS, undirectedS, - no_property, Weight > UndirectedGraph; - typedef adjacency_list < vecS, vecS, directedS, - no_property, Weight > DirectedGraph; + using Weight = property < edge_weight_t, double >; + using UndirectedGraph = adjacency_list < vecS, vecS, undirectedS, + no_property, Weight >; + using DirectedGraph = adjacency_list < vecS, vecS, directedS, + no_property, Weight >; undirected_graph_demo1 < UndirectedGraph > (); directed_graph_demo < DirectedGraph > (); undirected_graph_demo2 < UndirectedGraph > (); diff --git a/example/undirected_dfs.cpp b/example/undirected_dfs.cpp index bc314d39..1dec46d4 100644 --- a/example/undirected_dfs.cpp +++ b/example/undirected_dfs.cpp @@ -45,10 +45,10 @@ struct detect_loops : public boost::dfs_visitor<> int main(int, char*[]) { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, + using graph_t = adjacency_list< vecS, vecS, undirectedS, no_property, - property > graph_t; - typedef graph_traits::vertex_descriptor vertex_t; + property >; + using vertex_t = graph_traits::vertex_descriptor; const std::size_t N = sizeof(name)/sizeof(std::string); graph_t g(N); diff --git a/example/undirected_graph.cpp b/example/undirected_graph.cpp index 116d9552..d75ad94d 100644 --- a/example/undirected_graph.cpp +++ b/example/undirected_graph.cpp @@ -10,7 +10,7 @@ #include #include -typedef boost::undirected_graph Graph; +using Graph = boost::undirected_graph; int main(int,char*[]) { diff --git a/example/vector_as_graph.cpp b/example/vector_as_graph.cpp index f87d776b..e1b364f1 100644 --- a/example/vector_as_graph.cpp +++ b/example/vector_as_graph.cpp @@ -22,7 +22,7 @@ main() enum { r, s, t, u, v, w, x, y }; char name[] = "rstuvwxy"; - typedef std::vector < std::list < int > > Graph; + using Graph = std::vector < std::list < int > >; Graph g = { {v}, //r {r, r, w}, //s diff --git a/example/vertex-name-property.cpp b/example/vertex-name-property.cpp index 1e2d242f..e2adf00b 100644 --- a/example/vertex-name-property.cpp +++ b/example/vertex-name-property.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - typedef typename graph_traits < Graph >::vertices_size_type size_type; + using size_type = typename graph_traits < Graph >::vertices_size_type; size_type n_vertices; typename graph_traits < Graph >::vertex_descriptor u; typename property_traits < VertexNamePropertyMap >::value_type name; @@ -40,11 +40,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, int main() { - typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list + using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property < vertex_name_t, std::string > // Add a vertex property - >graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name = "makefile-dependencies.dat"; @@ -68,8 +68,8 @@ main() // Create storage for last modified times std::vector < time_t > last_mod_vec(num_vertices(g)); // Create nickname for the property map type - typedef iterator_property_map < std::vector < time_t >::iterator, - property_map < graph_type, vertex_index_t >::type, time_t, time_t& > iter_map_t; + using iter_map_t = iterator_property_map < std::vector < time_t >::iterator, + property_map < graph_type, vertex_index_t >::type, time_t, time_t& >; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index e30e04b2..12ce5d65 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -59,8 +59,8 @@ template struct print_edge { print_edge(Graph& g) : G(g) { } - typedef typename boost::graph_traits::edge_descriptor Edge; - typedef typename boost::graph_traits::vertex_descriptor Vertex; + using Edge = typename boost::graph_traits::edge_descriptor; + using Vertex = typename boost::graph_traits::vertex_descriptor; void operator()(Edge e) const { auto id = get(vertex_index, G); @@ -78,7 +78,7 @@ template struct print_index { print_index(Graph& g) : G(g){ } - typedef typename boost::graph_traits::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits::vertex_descriptor; void operator()(Vertex c) const { typename boost::property_map::type @@ -92,7 +92,7 @@ struct print_index { template struct exercise_vertex { - typedef typename boost::graph_traits::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits::vertex_descriptor; exercise_vertex(Graph& _g) : g(_g) { } @@ -128,9 +128,9 @@ struct exercise_vertex { int main() { - typedef adjacency_list MyGraphType; + using MyGraphType = adjacency_list; - typedef pair Pair; + using Pair = pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; diff --git a/example/vf2_sub_graph_iso_example.cpp b/example/vf2_sub_graph_iso_example.cpp index 8e17d2a7..c6b1010c 100644 --- a/example/vf2_sub_graph_iso_example.cpp +++ b/example/vf2_sub_graph_iso_example.cpp @@ -13,7 +13,7 @@ using namespace boost; int main() { - typedef adjacency_list graph_type; + using graph_type = adjacency_list; // Build graph1 int num_vertices1 = 8; graph_type graph1(num_vertices1); diff --git a/example/vf2_sub_graph_iso_multi_example.cpp b/example/vf2_sub_graph_iso_multi_example.cpp index 96ea96c4..98d26cc3 100644 --- a/example/vf2_sub_graph_iso_multi_example.cpp +++ b/example/vf2_sub_graph_iso_multi_example.cpp @@ -11,11 +11,11 @@ using namespace boost; int main() { - typedef property edge_property; - typedef property > vertex_property; + using edge_property = property; + using vertex_property = property >; // Using a vecS graphs => the index maps are implicit. - typedef adjacency_list graph_type; + using graph_type = adjacency_list; // Build graph1 graph_type graph1; diff --git a/example/visitor.cpp b/example/visitor.cpp index cd5b4f5a..d24487c5 100644 --- a/example/visitor.cpp +++ b/example/visitor.cpp @@ -49,7 +49,7 @@ using namespace std; template struct edge_printer : public base_visitor > { - typedef Tag event_filter; + using event_filter = Tag; edge_printer(std::string edge_t) : m_edge_type(edge_t) { } template void operator()(Edge e, Graph& G) { @@ -69,8 +69,8 @@ main(int, char*[]) using namespace boost; - typedef adjacency_list<> Graph; - typedef std::pair E; + using Graph = adjacency_list<>; + using E = std::pair; E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), @@ -84,7 +84,7 @@ main(int, char*[]) Graph G(edges, edges + sizeof(edges)/sizeof(E), 5); #endif - typedef boost::graph_traits::vertices_size_type size_type; + using size_type = boost::graph_traits::vertices_size_type; std::vector d(num_vertices(G)); std::vector f(num_vertices(G)); diff --git a/example/write_graphviz.cpp b/example/write_graphviz.cpp index 890f08cf..3aeded0a 100644 --- a/example/write_graphviz.cpp +++ b/example/write_graphviz.cpp @@ -25,7 +25,7 @@ const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", int main(int,char*[]) { - typedef std::pair Edge; + using Edge = std::pair; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), @@ -48,10 +48,10 @@ int main(int,char*[]) using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, + using Graph = adjacency_list< vecS, vecS, directedS, property< vertex_color_t, default_color_type >, property< edge_weight_t, int > - > Graph; + >; Graph g(used_by, used_by + nedges, weights, N); write_graphviz(std::cout, g, make_label_writer(name)); From 8064f3ec825a2cde2a57b0bf9581a5993c4cad4b Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 4 May 2016 13:51:39 +0200 Subject: [PATCH 08/28] examples: C++11: Use std::begin() and std::end(). Instead of array + length. And use initializer lists. --- example/bellman-ford-internet.cpp | 13 ++++++------- example/min_max_paths.cpp | 6 +++--- example/prim-example.cpp | 4 ++-- example/remove_edge_if_dir.cpp | 11 ++--------- example/stoer_wagner.cpp | 2 +- example/topo_sort.cpp | 21 +++++++++------------ example/visitor.cpp | 10 ++-------- 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/example/bellman-ford-internet.cpp b/example/bellman-ford-internet.cpp index 1f25316d..137a87c9 100644 --- a/example/bellman-ford-internet.cpp +++ b/example/bellman-ford-internet.cpp @@ -16,19 +16,18 @@ main() // ID numbers for the routers (vertices). enum { A, B, C, D, E, F, G, H, n_vertices }; - const int n_edges = 11; using Edge = std::pair < int, int >; // The list of connections between routers stored in an array. - Edge edges[] = { - Edge(A, B), Edge(A, C), - Edge(B, D), Edge(B, E), Edge(C, E), Edge(C, F), Edge(D, H), - Edge(D, E), Edge(E, H), Edge(F, G), Edge(G, H) + const auto edges = { + Edge(A, B), Edge(A, C), + Edge(B, D), Edge(B, E), Edge(C, E), Edge(C, F), Edge(D, H), + Edge(D, E), Edge(E, H), Edge(F, G), Edge(G, H) }; // Specify the graph type and declare a graph object - using Graph = edge_list < Edge*, Edge, std::ptrdiff_t, std::random_access_iterator_tag>; - Graph g(edges, edges + n_edges); + using Graph = edge_list < const Edge*, Edge, std::ptrdiff_t, std::random_access_iterator_tag>; + Graph g(std::begin(edges), std::end(edges)); // The transmission delay values for each edge. float delay[] = diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index a20d84a6..f1168b1b 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -51,7 +51,7 @@ main(int , char* []) const char name[] = "abcdef"; const int num_nodes = 6; - E edges[] = { E(0,2), E(1,1), E(1,3), E(1,4), E(2,1), E(2,3), + const auto edges = { E(0,2), E(1,1), E(1,3), E(1,4), E(2,1), E(2,3), E(3,4), E(4,0), E(4,1) }; int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1}; const int n_edges = sizeof(edges)/sizeof(E); @@ -65,8 +65,8 @@ main(int , char* []) weightmap[e] = weights[j]; } #else - Graph G(edges, edges + n_edges, weights, num_nodes); - auto weightmap = get(edge_weight, G); + Graph G(std::begin(edges), std::end(edges), weights, num_nodes); + auto = get(edge_weight, G); #endif std::vector p(num_vertices(G)); diff --git a/example/prim-example.cpp b/example/prim-example.cpp index 49607a97..bf8d2f22 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -18,7 +18,7 @@ main() property, property < edge_weight_t, int > >; using E = std::pair < int, int>; const int num_nodes = 5; - E edges[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), + const auto edges = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) }; int weights[] = { 1, 1, 2, 7, 3, 1, 1 }; @@ -31,7 +31,7 @@ main() weightmap[e] = weights[j]; } #else - Graph g(edges, edges + sizeof(edges) / sizeof(E), weights, num_nodes); + Graph g(std::begin(edges), std::end(edges), weights, num_nodes); #endif std::vector < graph_traits < Graph >::vertex_descriptor > p(num_vertices(g)); diff --git a/example/remove_edge_if_dir.cpp b/example/remove_edge_if_dir.cpp index c44acf78..830ae7dd 100644 --- a/example/remove_edge_if_dir.cpp +++ b/example/remove_edge_if_dir.cpp @@ -43,19 +43,12 @@ int main() { using Edge = std::pair; - Edge edges[6] = { Edge(0,3), Edge(0,2), Edge(0, 3), + const auto edges = { Edge(0,3), Edge(0,2), Edge(0, 3), Edge(1,3), Edge(2, 0), Edge(3, 2) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - // VC++ can't handle iterator constructor - Graph g(4); - for (std::size_t j = 0; j < 6; ++j) - add_edge(edges[j].first, edges[j].second, g); -#else - Graph g(edges, edges + 6, 4); -#endif + Graph g(std::begin(edges), std::end(edges), 4); std::cout << "original graph:" << std::endl; print_graph(g, get(vertex_index, g)); diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index 1a39764e..13388d89 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -40,7 +40,7 @@ int main() // construct the graph object. 8 is the number of vertices, which are numbered from 0 // through 7, and 16 is the number of edges. - undirected_graph g(edges, edges + 16, ws, 8, 16); + undirected_graph g(std::begin(edges), std::end(edges), ws, 8, 16); // define a property map, `parities`, that will store a boolean value for each vertex. // Vertices that have the same parity after `stoer_wagner_min_cut` runs are on the same side of the min-cut. diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index f66d9af6..e57e5517 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -44,18 +44,15 @@ main(int , char* []) property >; using Vertex = boost::graph_traits::vertex_descriptor; - Pair edges[6] = { Pair(0,1), Pair(2,4), - Pair(2,5), - Pair(0,3), Pair(1,4), - Pair(4,3) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - // VC++ can't handle the iterator constructor - Graph G(6); - for (std::size_t j = 0; j < 6; ++j) - add_edge(edges[j].first, edges[j].second, G); -#else - Graph G(edges, edges + 6, 6); -#endif + + const auto edges = { + Pair(0, 1), + Pair(2, 4), + Pair(2, 5), + Pair(0, 3), + Pair(1, 4), + Pair(4, 3) }; + Graph G(std::begin(edges), std::end(edges), 6 /* vertices count */); auto id = get(vertex_index, G); diff --git a/example/visitor.cpp b/example/visitor.cpp index d24487c5..335b21a0 100644 --- a/example/visitor.cpp +++ b/example/visitor.cpp @@ -71,18 +71,12 @@ main(int, char*[]) using Graph = adjacency_list<>; using E = std::pair; - E edges[] = { E(0, 2), + const auto edges = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1), E(3, 4), E(4, 0), E(4, 1) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - Graph G(5); - for (std::size_t j = 0; j < sizeof(edges)/sizeof(E); ++j) - add_edge(edges[j].first, edges[j].second, G); -#else - Graph G(edges, edges + sizeof(edges)/sizeof(E), 5); -#endif + Graph G(std::begin(edges), std::end(edges), 5); using size_type = boost::graph_traits::vertices_size_type; From dcef7953074ed61df73ed6f47f723c49f9331e1d Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 5 May 2016 22:02:22 +0200 Subject: [PATCH 09/28] examples: C++11: Remove spaces from around < and > for templates. This is not necessary in C++11 and it is not a common style. --- example/accum-compile-times.cpp | 20 +++++----- example/actor_clustering.cpp | 4 +- example/adjacency_list_io.cpp | 4 +- example/astar-cities.cpp | 2 +- example/astar_maze.cpp | 2 +- example/bellman-example.cpp | 16 ++++---- example/bellman-ford-internet.cpp | 6 +-- example/bfs-example.cpp | 20 +++++----- example/bfs-example2.cpp | 16 ++++---- example/bfs.cpp | 4 +- example/bfs_neighbor.cpp | 4 +- example/biconnected_components.cpp | 8 ++-- example/boost_web_graph.cpp | 4 +- example/boykov_kolmogorov-eg.cpp | 10 ++--- example/canonical_ordering.cpp | 13 +++---- example/cc-internet.cpp | 2 +- example/connected-components.cpp | 4 +- example/container_gen.cpp | 4 +- example/copy-example.cpp | 8 ++-- example/cuthill_mckee_ordering.cpp | 2 +- example/cycle-file-dep.cpp | 25 ++++++------ example/cycle-file-dep2.cpp | 25 ++++++------ example/cycle_ratio_example.cpp | 4 +- example/dag_shortest_paths.cpp | 2 +- example/dave.cpp | 10 ++--- example/default-constructor.cpp | 4 +- example/default-constructor2.cpp | 8 ++-- example/dfs-example.cpp | 30 +++++++------- example/dfs-parenthesis.cpp | 2 +- example/dijkstra-example-listS.cpp | 10 ++--- example/dijkstra-example.cpp | 10 ++--- example/dijkstra-no-color-map-example.cpp | 12 +++--- example/edge-connectivity.cpp | 40 +++++++++---------- example/edge-function.cpp | 40 +++++++++---------- example/edge-iter-constructor.cpp | 8 ++-- example/edmonds-karp-eg.cpp | 10 ++--- example/exterior_properties.cpp | 2 +- example/fibonacci_heap.cpp | 4 +- example/filtered-copy-example.cpp | 8 ++-- example/filtered_graph.cpp | 4 +- example/filtered_graph_edge_range.cpp | 2 +- example/filtered_vec_as_graph.cpp | 2 +- example/fr_layout.cpp | 2 +- example/gerdemann.cpp | 2 +- example/graph-assoc-types.cpp | 44 ++++++++++----------- example/graph-property-iter-eg.cpp | 8 ++-- example/graph-thingie.cpp | 16 ++++---- example/graph.cpp | 2 +- example/graph_as_tree.cpp | 2 +- example/graph_property.cpp | 2 +- example/graphviz.cpp | 4 +- example/implicit_graph.cpp | 4 +- example/inclusive_mean_geodesic.cpp | 2 +- example/interior_property_map.cpp | 2 +- example/isomorphism.cpp | 2 +- example/iteration_macros.cpp | 4 +- example/iterator-property-map-eg.cpp | 2 +- example/johnson-eg.cpp | 10 ++--- example/kevin-bacon.cpp | 21 +++++----- example/king_ordering.cpp | 2 +- example/knights_tour.cpp | 32 +++++++-------- example/kruskal-example.cpp | 8 ++-- example/kruskal-telephone.cpp | 16 ++++---- example/kuratowski_subgraph.cpp | 13 +++---- example/last-mod-time.cpp | 22 +++++------ example/leda-concept-check.cpp | 4 +- example/leda-graph-eg.cpp | 6 +-- example/loops_dfs.cpp | 46 +++++++++++----------- example/make_biconnected_planar.cpp | 15 +++---- example/make_connected.cpp | 11 ++---- example/make_maximal_planar.cpp | 13 +++---- example/max_flow.cpp | 2 +- example/mcgregor_subgraphs_example.cpp | 4 +- example/min_max_paths.cpp | 2 +- example/modify_graph.cpp | 2 +- example/ordered_out_edges.cpp | 4 +- example/ospf-example.cpp | 24 ++++++------ example/parallel-compile-time.cpp | 58 ++++++++++++++-------------- example/planar_face_traversal.cpp | 2 +- example/prim-example.cpp | 6 +-- example/prim-telephone.cpp | 12 +++--- example/print-adjacent-vertices.cpp | 30 +++++++------- example/print-edges.cpp | 16 ++++---- example/print-in-edges.cpp | 30 +++++++------- example/print-out-edges.cpp | 34 ++++++++-------- example/property-map-traits-eg.cpp | 6 +-- example/property_iterator.cpp | 6 +-- example/push-relabel-eg.cpp | 10 ++--- example/put-get-helper-eg.cpp | 16 ++++---- example/quick-tour.cpp | 24 ++++++------ example/quick_tour.cpp | 2 +- example/r_c_shortest_paths_example.cpp | 8 ++-- example/reachable-loop-head.cpp | 8 ++-- example/reachable-loop-tail.cpp | 10 ++--- example/read_graphviz.cpp | 8 ++-- example/read_write_dimacs-eg.cpp | 10 ++--- example/remove_edge_if_bidir.cpp | 2 +- example/remove_edge_if_undir.cpp | 2 +- example/reverse_graph.cpp | 2 +- example/roget_components.cpp | 2 +- example/scaled_closeness_centrality.cpp | 2 +- example/scc.cpp | 6 +-- example/sloan_ordering.cpp | 2 +- example/stoer_wagner.cpp | 2 +- example/straight_line_drawing.cpp | 15 +++---- example/strong-components.cpp | 2 +- example/strong_components.cpp | 2 +- example/subgraph.cpp | 4 +- example/subgraph_properties.cpp | 8 ++-- example/topo-sort-file-dep.cpp | 26 ++++++------- example/topo-sort-file-dep2.cpp | 34 ++++++++-------- example/topo-sort-with-leda.cpp | 10 ++--- example/topo-sort-with-sgb.cpp | 4 +- example/topo-sort1.cpp | 4 +- example/topo-sort2.cpp | 4 +- example/topo_sort.cpp | 4 +- example/transitive_closure.cpp | 10 ++--- example/transpose-example.cpp | 10 ++--- example/two_graphs_common_spanning_trees.cpp | 8 ++-- example/undirected_adjacency_list.cpp | 22 +++++------ example/undirected_dfs.cpp | 2 +- example/vector_as_graph.cpp | 2 +- example/vertex-name-property.cpp | 16 ++++---- example/vf2_sub_graph_iso_multi_example.cpp | 2 +- example/visitor.cpp | 2 +- example/write_graphviz.cpp | 6 +-- 126 files changed, 631 insertions(+), 652 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index aef1085e..03ebc590 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -16,8 +16,8 @@ namespace std { - template < typename T > - std::istream& operator >> (std::istream& in, std::pair < T, T > &p) + template + std::istream& operator >> (std::istream& in, std::pair &p) { in >> p.first >> p.second; return in; @@ -32,16 +32,16 @@ namespace boost using namespace boost; -using file_dep_graph2 = adjacency_list< listS, // Store out-edges of each vertex in a std::list +using file_dep_graph2 = adjacency_list > > >, + property>>>, // an edge property - property < edge_weight_t, float > >; + property>; using vertex_t = graph_traits::vertex_descriptor; using edge_t = graph_traits::edge_descriptor; @@ -63,7 +63,7 @@ main() while (file_in >> p) add_edge(id2vertex[p.first], id2vertex[p.second], g); #else - std::istream_iterator > + std::istream_iterator> input_begin(file_in), input_end; file_dep_graph2 g(input_begin, input_end, n_vertices); #endif @@ -75,7 +75,7 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); - graph_traits < file_dep_graph2 >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 11fa3ce0..92923bba 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -35,7 +35,7 @@ struct Actor }; using ActorGraph = adjacency_list >; + property>; using Vertex = graph_traits::vertex_descriptor; using Edge = graph_traits::edge_descriptor; @@ -48,7 +48,7 @@ void load_actor_graph(std::istream& in, ActorGraph& g) std::vector actors_in_movie; // Map from the actor numbers on this line to the actor vertices - using Tok = tokenizer >; + using Tok = tokenizer>; Tok tok(line, char_separator(" ")); for (const auto& id : tok) { auto actor_id = lexical_cast(id); diff --git a/example/adjacency_list_io.cpp b/example/adjacency_list_io.cpp index 5dad6b83..79bae4dc 100644 --- a/example/adjacency_list_io.cpp +++ b/example/adjacency_list_io.cpp @@ -33,7 +33,7 @@ struct n2_t { enum { num = 23062}; using kind = vertex_property_tag; }; struct n3_t { enum { num = 23061}; using kind = vertex_property_tag; }; using VertexProperty = property< n1_t, int, property< n2_t, double, - property< n3_t, MyStruct > > >; + property>>; //====== edge properties @@ -82,7 +82,7 @@ main() // read Graph2, incomplete data in a different order. Write it diffently. Graph2 g31; std::ifstream readFile31("data3.txt"); - using readNodeProp = property< n3_t, MyStruct, property< n1_t, int > >; + using readNodeProp = property>; readFile31 >> read( g31, readNodeProp() , EdgeProperty() ); std::cout << "graph g31 from file data3.txt:\n" << write( g31, property(), EdgeProperty() ) diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index dc628f58..0540fee6 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -114,7 +114,7 @@ int main(int argc, char **argv) // specify some types using mygraph_t = adjacency_list >; + property>; using WeightMap = property_map::type; using vertex = mygraph_t::vertex_descriptor; using edge_descriptor = mygraph_t::edge_descriptor; diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index e1c5e14b..03f23186 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -247,7 +247,7 @@ std::size_t random_int(std::size_t a, std::size_t b) { if (b < a) b = a; boost::uniform_int<> dist(a, b); - boost::variate_generator > + boost::variate_generator> generate(random_generator, dist); return generate(); } diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index a62c1386..84db1b41 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -15,7 +15,7 @@ using namespace boost; -template < typename Graph, typename ParentMap > +template struct edge_writer { edge_writer(const Graph & g, const ParentMap & p) @@ -23,7 +23,7 @@ struct edge_writer { } - template < typename Edge > + template void operator() (std::ostream & out, const Edge & e) const { out << "[label=\"" << get(edge_weight, m_g, e) << "\""; @@ -37,11 +37,11 @@ struct edge_writer const Graph & m_g; ParentMap m_parent; }; -template < typename Graph, typename Parent > -edge_writer < Graph, Parent > +template +edge_writer make_edge_writer(const Graph & g, const Parent & p) { - return edge_writer < Graph, Parent > (g, p); + return edge_writer (g, p); } struct EdgeProperties { @@ -53,7 +53,7 @@ main() { enum { u, v, x, y, z, N }; char name[] = { 'u', 'v', 'x', 'y', 'z' }; - using E = std::pair < int, int >; + using E = std::pair; const int n_edges = 10; E edge_array[] = { E(u, y), E(u, x), E(u, v), E(v, u), E(x, y), E(x, v), E(y, v), E(y, z), E(z, u), E(z,x) }; @@ -69,13 +69,13 @@ main() #else Graph g(edge_array, edge_array + n_edges, N); #endif - graph_traits < Graph >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; auto weight_pmap = get(&EdgeProperties::weight, g); int i = 0; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) weight_pmap[*ei] = weight[i]; - std::vector distance(N, (std::numeric_limits < short >::max)()); + std::vector distance(N, (std::numeric_limits::max)()); std::vector parent(N); for (i = 0; i < N; ++i) parent[i] = i; diff --git a/example/bellman-ford-internet.cpp b/example/bellman-ford-internet.cpp index 137a87c9..ee454815 100644 --- a/example/bellman-ford-internet.cpp +++ b/example/bellman-ford-internet.cpp @@ -16,7 +16,7 @@ main() // ID numbers for the routers (vertices). enum { A, B, C, D, E, F, G, H, n_vertices }; - using Edge = std::pair < int, int >; + using Edge = std::pair; // The list of connections between routers stored in an array. const auto edges = { @@ -26,7 +26,7 @@ main() }; // Specify the graph type and declare a graph object - using Graph = edge_list < const Edge*, Edge, std::ptrdiff_t, std::random_access_iterator_tag>; + using Graph = edge_list ; Graph g(std::begin(edges), std::end(edges)); // The transmission delay values for each edge. @@ -39,7 +39,7 @@ main() for (int i = 0; i < n_vertices; ++i) parent[i] = i; float distance[n_vertices]; - std::fill(distance, distance + n_vertices, (std::numeric_limits < float >::max)()); + std::fill(distance, distance + n_vertices, (std::numeric_limits::max)()); // Specify A as the source vertex distance[A] = 0; diff --git a/example/bfs-example.cpp b/example/bfs-example.cpp index 56e73240..1723ede1 100644 --- a/example/bfs-example.cpp +++ b/example/bfs-example.cpp @@ -13,11 +13,11 @@ #include using namespace boost; -template < typename TimeMap > class bfs_time_visitor:public default_bfs_visitor { - using T = typename property_traits < TimeMap >::value_type; +template class bfs_time_visitor:public default_bfs_visitor { + using T = typename property_traits::value_type; public: bfs_time_visitor(TimeMap tmap, T & t):m_timemap(tmap), m_time(t) { } - template < typename Vertex, typename Graph > + template void discover_vertex(Vertex u, const Graph & g) const { put(m_timemap, u, m_time++); @@ -32,12 +32,12 @@ main() { using namespace boost; // Select the graph type we wish to use - using graph_t = adjacency_list < vecS, vecS, undirectedS >; + using graph_t = adjacency_list; // Set up the vertex IDs and names enum { r, s, t, u, v, w, x, y, N }; const char *name = "rstuvwxy"; // Specify the edges in the graph - using E = std::pair < int, int >; + using E = std::pair; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; @@ -54,25 +54,25 @@ main() #endif // Typedefs - using Size = graph_traits < graph_t >::vertices_size_type; + using Size = graph_traits::vertices_size_type; // a vector to hold the discover time property for each vertex - std::vector < Size > dtime(num_vertices(g)); + std::vector dtime(num_vertices(g)); using dtime_pm_type = iterator_property_map::iterator, property_map::const_type>; dtime_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); Size time = 0; - bfs_time_visitor < dtime_pm_type >vis(dtime_pm, time); + bfs_time_visitor vis(dtime_pm, time); breadth_first_search(g, vertex(s, g), visitor(vis)); // Use std::sort to order the vertices by their discover time std::vector::vertices_size_type > discover_order(N); - integer_range < int >range(0, N); + integer_range range(0, N); std::copy(range.begin(), range.end(), discover_order.begin()); std::sort(discover_order.begin(), discover_order.end(), - indirect_cmp < dtime_pm_type, std::less < Size > >(dtime_pm)); + indirect_cmp>(dtime_pm)); std::cout << "order of discovery: "; for (int i = 0; i < N; ++i) diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index d47d0292..c8ea003c 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -14,11 +14,11 @@ #include using namespace boost; -template < typename TimeMap > class bfs_time_visitor:public default_bfs_visitor { - using T = typename property_traits < TimeMap >::value_type; +template class bfs_time_visitor:public default_bfs_visitor { + using T = typename property_traits::value_type; public: bfs_time_visitor(TimeMap tmap, T & t):m_timemap(tmap), m_time(t) { } - template < typename Vertex, typename Graph > + template void discover_vertex(Vertex u, const Graph & g) const { put(m_timemap, u, m_time++); @@ -39,13 +39,13 @@ main() { using namespace boost; // Select the graph type we wish to use - using graph_t = adjacency_list < listS, listS, undirectedS, + using graph_t = adjacency_list; // Set up the vertex IDs and names enum { r, s, t, u, v, w, x, y, N }; const char *name = "rstuvwxy"; // Specify the edges in the graph - using E = std::pair < int, int >; + using E = std::pair; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; @@ -70,12 +70,12 @@ main() Size time = 0; using dtime_map_t = property_map::type; auto dtime_map = get(&VertexProps::discover_time, g); - bfs_time_visitor < dtime_map_t > vis(dtime_map, time); + bfs_time_visitor vis(dtime_map, time); breadth_first_search(g, vertex(s, g), color_map(get(&VertexProps::color, g)). visitor(vis)); // a vector to hold the discover time property for each vertex - std::vector < Size > dtime(num_vertices(g)); + std::vector dtime(num_vertices(g)); using dtime_pm_type = iterator_property_map::iterator, property_map::type>; @@ -89,7 +89,7 @@ main() // Use std::sort to order the vertices by their discover time std::vector::vertices_size_type > discover_order(N); - integer_range < int >range(0, N); + integer_range range(0, N); std::copy(range.begin(), range.end(), discover_order.begin()); std::sort(discover_order.begin(), discover_order.end(), make_indirect_cmp( diff --git a/example/bfs.cpp b/example/bfs.cpp index 39cc7c5a..0c6fd746 100644 --- a/example/bfs.cpp +++ b/example/bfs.cpp @@ -69,7 +69,7 @@ struct print_parent { template struct graph_copier - : public boost::base_visitor > + : public boost::base_visitor> { using event_filter = Tag; @@ -96,7 +96,7 @@ int main(int , char* []) boost::property > > > + boost::property>>> >; Graph G(5); diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index 148f90cc..1f18b6c6 100644 --- a/example/bfs_neighbor.cpp +++ b/example/bfs_neighbor.cpp @@ -64,7 +64,7 @@ struct print_parent { template struct graph_copier - : public boost::base_visitor > + : public boost::base_visitor> { using event_filter = Tag; @@ -91,7 +91,7 @@ int main(int , char* []) boost::property > > > + boost::property>>> >; Graph G(5); diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 8a9ac16f..4654807b 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -28,9 +28,9 @@ int main() { using namespace boost; - using graph_t = adjacency_list < vecS, vecS, undirectedS, - no_property, property < edge_component_t, std::size_t > >; - using vertex_t = graph_traits < graph_t >::vertex_descriptor; + using graph_t = adjacency_list>; + using vertex_t = graph_traits::vertex_descriptor; graph_t g(9); add_edge(0, 5, g); add_edge(0, 1, g); @@ -61,7 +61,7 @@ main() << std::endl; } - graph_traits < graph_t >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) std::cout << (char)(source(*ei, g) + 'A') << " -- " << (char)(target(*ei, g) + 'A') diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index 6cf3eccd..ba82eafb 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -84,8 +84,8 @@ main() using Graph = adjacency_list >, - property > + property>, + property> >; using Traits = graph_traits; diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index 64cf1b90..2258f664 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -70,17 +70,17 @@ int main() { using namespace boost; - using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Traits = adjacency_list_traits; using Graph = adjacency_list < vecS, vecS, directedS, property < vertex_name_t, std::string, property < vertex_index_t, long, property < vertex_color_t, boost::default_color_type, property < vertex_distance_t, long, - property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, + property>>>>, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > >; + property>>>; Graph g; auto capacity = get(edge_capacity, g); @@ -97,8 +97,8 @@ int main() std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits < Graph >::vertex_iterator u_iter, u_end; - graph_traits < Graph >::out_edge_iterator ei, e_end; + graph_traits::vertex_iterator u_iter, u_end; + graph_traits::out_edge_iterator ei, e_end; for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index c1b85a60..3ab48a5a 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -23,13 +23,10 @@ using namespace boost; int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property, - property - >; + using graph = adjacency_list, + property>; // Create a maximal planar graph on 6 vertices graph g(6); @@ -59,7 +56,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - using vec_t = std::vector< graph_traits::edge_descriptor >; + using vec_t = std::vector::edge_descriptor>; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = diff --git a/example/cc-internet.cpp b/example/cc-internet.cpp index 2ce0f61e..a1e83cb7 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -28,7 +28,7 @@ main() auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; - graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 9e556afc..0160d102 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -15,7 +15,7 @@ int main() { using namespace boost; - using Graph = adjacency_list < vecS, vecS, undirectedS >; + using Graph = adjacency_list; const int N = 6; Graph G(N); @@ -29,7 +29,7 @@ main() (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); std::cout << std::endl; - std::vector < int >::iterator i; + std::vector::iterator i; std::cout << "Total number of components: " << num << std::endl; for (i = c.begin(); i != c.end(); ++i) std::cout << "Vertex " << i - c.begin() diff --git a/example/container_gen.cpp b/example/container_gen.cpp index 1dbfe079..66a2ec00 100644 --- a/example/container_gen.cpp +++ b/example/container_gen.cpp @@ -20,14 +20,14 @@ namespace boost { using type = std::list; }; template - struct parallel_edge_traits< list_with_allocatorS > { + struct parallel_edge_traits> { using type = allow_parallel_edge_tag; }; } // now you can define a graph using std::list and a specific allocator -using MyGraph = boost::adjacency_list< list_with_allocatorS< std::allocator >, +using MyGraph = boost::adjacency_list>, boost::vecS, boost::directedS>; int main(int, char*[]) diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 07b51404..5cd5a48e 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -15,19 +15,19 @@ int main() { using namespace boost; - using graph_t = adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, char > >; + using graph_t = adjacency_list>; enum { a, b, c, d, e, f, g, N }; graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits < graph_t >::vertex_iterator v, v_end; + graph_traits::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - using E = std::pair < int, int >; + using E = std::pair; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 580a79e9..43b98512 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -35,7 +35,7 @@ int main(int , char* []) using namespace std; using Graph = adjacency_list > >; + property>>; using Vertex = graph_traits::vertex_descriptor; using size_type = graph_traits::vertices_size_type; diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index 9577c110..4fd4ee46 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -16,28 +16,28 @@ using namespace boost; namespace std { - template < typename T > - std::istream & operator >> (std::istream & in, std::pair < T, T > &p) + template + std::istream & operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return in; } } -using file_dep_graph = adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph = adjacency_list; -using vertex_t = graph_traits < file_dep_graph >::vertex_descriptor; -using edge_t = graph_traits < file_dep_graph >::edge_descriptor; +using vertex_t = graph_traits::vertex_descriptor; +using edge_t = graph_traits::edge_descriptor; bool has_cycle_dfs(const file_dep_graph & g, vertex_t u, default_color_type * color) { color[u] = gray_color; - graph_traits < file_dep_graph >::adjacency_iterator vi, vi_end; + graph_traits::adjacency_iterator vi, vi_end; for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (color[*vi] == white_color) { if (has_cycle_dfs(g, *vi, color)) @@ -51,8 +51,8 @@ has_cycle_dfs(const file_dep_graph & g, vertex_t u, bool has_cycle(const file_dep_graph & g) { - std::vector < default_color_type > color(num_vertices(g), white_color); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + std::vector color(num_vertices(g), white_color); + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (color[*vi] == white_color) if (has_cycle_dfs(g, *vi, &color[0])) @@ -65,11 +65,10 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - using size_type = graph_traits < file_dep_graph >::vertices_size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices - std::istream_iterator < std::pair < size_type, - size_type > > input_begin(file_in), input_end; + std::istream_iterator> input_begin(file_in), input_end; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ has trouble with the edge iterator constructor file_dep_graph g(n_vertices); @@ -82,9 +81,9 @@ main() file_dep_graph g(input_begin, input_end, n_vertices); #endif - std::vector < std::string > name(num_vertices(g)); + std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index 3906431d..f2f6effe 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -18,7 +18,7 @@ using namespace boost; namespace std { template - std::istream& operator >> (std::istream & in, std::pair < T, T > &p) + std::istream& operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return @@ -35,13 +35,13 @@ using file_dep_graph = adjacency_list< using vertex_t = graph_traits::vertex_descriptor; using edge_t = graph_traits::edge_descriptor; -template < typename Visitor > void +template void dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, Visitor vis) { color[u] = gray_color; vis.discover_vertex(u, g); - graph_traits < file_dep_graph >::out_edge_iterator ei, ei_end; + graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); @@ -55,11 +55,11 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, vis.finish_vertex(u, g); } -template < typename Visitor > void +template void generic_dfs_v1(const file_dep_graph & g, Visitor vis) { - std::vector < default_color_type > color(num_vertices(g), white_color); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + std::vector color(num_vertices(g), white_color); + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); @@ -78,17 +78,17 @@ struct dfs_visitor_default { } - template < typename E, typename G > void + template void back_edge(E, const G &) { } - template < typename E, typename G > void + template void forward_or_cross_edge(E, const G &) { } - template < typename V, typename G > void + template void finish_vertex(V, const G &) { } @@ -125,8 +125,7 @@ main() using size_type = graph_traits ::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices - std::istream_iterator < std::pair < size_type, - size_type > >input_begin(file_in), input_end; + std::istream_iterator> input_begin(file_in), input_end; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ has trouble with the edge iterator constructor file_dep_graph g(n_vertices); @@ -139,9 +138,9 @@ main() file_dep_graph g(input_begin, input_end, n_vertices); #endif - std::vector < std::string > name(num_vertices(g)); + std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 98b19f96..4887f386 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -34,10 +34,10 @@ void gen_rand_graph(TG &g, size_t nV, size_t nE) rng.seed(uint32_t(time(0))); boost::generate_random_graph(g, nV, nE, rng, true, true); boost::uniform_real<> ur(-1,10); - boost::variate_generator > ew1rg(rng, ur); + boost::variate_generator> ew1rg(rng, ur); randomize_property(g, ew1rg); boost::uniform_int uint(1,5); - boost::variate_generator > ew2rg(rng, uint); + boost::variate_generator> ew2rg(rng, uint); randomize_property(g, ew2rg); } diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 17563bda..0396c815 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -26,7 +26,7 @@ int main() { using namespace boost; using graph_t = adjacency_list, property >; + property, property>; graph_t g(6); enum verts { r, s, t, u, v, x }; char name[] = "rstuvx"; diff --git a/example/dave.cpp b/example/dave.cpp index 1972c3ba..884c9243 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -72,7 +72,7 @@ b(14); d a */ using VProperty = property >; + property>; using weight_t = int; using EProperty = property; @@ -82,7 +82,7 @@ using Graph = adjacency_list; template struct endl_printer - : public boost::base_visitor< endl_printer > + : public boost::base_visitor> { using event_filter = Tag; endl_printer(std::ostream& os) : m_os(os) { } @@ -97,7 +97,7 @@ endl_printer print_endl(std::ostream& os, Tag) { template struct edge_printer - : public boost::base_visitor< edge_printer > + : public boost::base_visitor> { using event_filter = Tag; @@ -120,7 +120,7 @@ print_edge(PA pa, std::ostream& os, Tag) { template struct graph_copier - : public boost::base_visitor > + : public boost::base_visitor> { using event_filter = Tag; @@ -190,7 +190,7 @@ main(int , char* []) print(G, name); adjacency_list > G_copy(N); + property> G_copy(N); cout << "Starting graph:" << endl; diff --git a/example/default-constructor.cpp b/example/default-constructor.cpp index dc3a4dc6..eff073c0 100644 --- a/example/default-constructor.cpp +++ b/example/default-constructor.cpp @@ -11,10 +11,10 @@ using namespace boost; -template < typename Graph > void +template void read_graph_file(std::istream & in, Graph & g) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) // Add n vertices to the graph diff --git a/example/default-constructor2.cpp b/example/default-constructor2.cpp index cc89a410..88694aa5 100644 --- a/example/default-constructor2.cpp +++ b/example/default-constructor2.cpp @@ -11,14 +11,14 @@ using namespace boost; -template < typename Graph > void +template void read_graph_file(std::istream & in, Graph & g) { - using Vertex = typename graph_traits < Graph >::vertex_descriptor; - using size_type = typename graph_traits < Graph >::vertices_size_type; + using Vertex = typename graph_traits::vertex_descriptor; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices - std::vector < Vertex > vertex_set(n_vertices); + std::vector vertex_set(n_vertices); for (size_type i = 0; i < n_vertices; ++i) vertex_set[i] = add_vertex(g); diff --git a/example/dfs-example.cpp b/example/dfs-example.cpp index 876de223..ff0fe70d 100644 --- a/example/dfs-example.cpp +++ b/example/dfs-example.cpp @@ -13,18 +13,18 @@ #include using namespace boost; -template < typename TimeMap > class dfs_time_visitor:public default_dfs_visitor { - using T = typename property_traits < TimeMap >::value_type; +template class dfs_time_visitor:public default_dfs_visitor { + using T = typename property_traits::value_type; public: dfs_time_visitor(TimeMap dmap, TimeMap fmap, T & t) : m_dtimemap(dmap), m_ftimemap(fmap), m_time(t) { } - template < typename Vertex, typename Graph > + template void discover_vertex(Vertex u, const Graph & g) const { put(m_dtimemap, u, m_time++); } - template < typename Vertex, typename Graph > + template void finish_vertex(Vertex u, const Graph & g) const { put(m_ftimemap, u, m_time++); @@ -39,14 +39,14 @@ int main() { // Select the graph type we wish to use - using graph_t = adjacency_list < vecS, vecS, directedS >; - using size_type = graph_traits < graph_t >::vertices_size_type; + using graph_t = adjacency_list; + using size_type = graph_traits::vertices_size_type; // Set up the vertex names enum { u, v, w, x, y, z, N }; char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' }; // Specify the edges in the graph - using E = std::pair < int, int >; + using E = std::pair; E edge_array[] = { E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y), E(w, z), E(z, z) }; @@ -59,33 +59,33 @@ main() #endif // discover time and finish time properties - std::vector < size_type > dtime(num_vertices(g)); - std::vector < size_type > ftime(num_vertices(g)); + std::vector dtime(num_vertices(g)); + std::vector ftime(num_vertices(g)); using time_pm_type = iterator_property_map::iterator, property_map::const_type>; time_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); time_pm_type ftime_pm(ftime.begin(), get(vertex_index, g)); size_type t = 0; - dfs_time_visitor < time_pm_type >vis(dtime_pm, ftime_pm, t); + dfs_time_visitor vis(dtime_pm, ftime_pm, t); depth_first_search(g, visitor(vis)); // use std::sort to order the vertices by their discover time - std::vector < size_type > discover_order(N); - integer_range < size_type > r(0, N); + std::vector discover_order(N); + integer_range r(0, N); std::copy(r.begin(), r.end(), discover_order.begin()); std::sort(discover_order.begin(), discover_order.end(), - indirect_cmp < time_pm_type, std::less < size_type > >(dtime_pm)); + indirect_cmp>(dtime_pm)); std::cout << "order of discovery: "; int i; for (i = 0; i < N; ++i) std::cout << name[discover_order[i]] << " "; - std::vector < size_type > finish_order(N); + std::vector finish_order(N); std::copy(r.begin(), r.end(), finish_order.begin()); std::sort(finish_order.begin(), finish_order.end(), - indirect_cmp < time_pm_type, std::less < size_type > >(ftime_pm)); + indirect_cmp>(ftime_pm)); std::cout << std::endl << "order of finish: "; for (i = 0; i < N; ++i) std::cout << name[finish_order[i]] << " "; diff --git a/example/dfs-parenthesis.cpp b/example/dfs-parenthesis.cpp index 1078f90b..5c38d83e 100644 --- a/example/dfs-parenthesis.cpp +++ b/example/dfs-parenthesis.cpp @@ -35,7 +35,7 @@ main() using namespace boost; GraphvizGraph g; read_graphviz("figs/dfs-example.dot", g); - graph_traits < GraphvizGraph >::edge_iterator e, e_end; + graph_traits::edge_iterator e, e_end; for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) std::cout << '(' << name[source(*e, g)] << ' ' << name[target(*e, g)] << ')' << std::endl; diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 07cc1694..fb363649 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -20,12 +20,12 @@ main(int, char *[]) { using vertex_descriptor = adjacency_list_traits::vertex_descriptor; - using graph_t = adjacency_list < listS, listS, directedS, + using graph_t = adjacency_list > > >, - property >; + property>>>, + property>; using Edge = std::pair; const int num_nodes = 5; @@ -56,7 +56,7 @@ main(int, char *[]) dijkstra_shortest_paths(g, s, predecessor_map(p).distance_map(d)); std::cout << "distances and parents:" << std::endl; - graph_traits < graph_t >::vertex_iterator vi, vend; + graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: @@ -71,7 +71,7 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits < graph_t >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { auto e = *ei; auto u = source(e, g), v = target(e, g); diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 2cb8f1ee..011c95f5 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -19,9 +19,9 @@ using namespace boost; int main(int, char *[]) { - using graph_t = adjacency_list < listS, vecS, directedS, - no_property, property < edge_weight_t, int > >; - using vertex_descriptor = graph_traits < graph_t >::vertex_descriptor; + using graph_t = adjacency_list >; + using vertex_descriptor = graph_traits::vertex_descriptor; using Edge = std::pair; const int num_nodes = 5; @@ -43,7 +43,7 @@ main(int, char *[]) distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g)))); std::cout << "distances and parents:" << std::endl; - graph_traits < graph_t >::vertex_iterator vi, vend; + graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: @@ -59,7 +59,7 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits < graph_t >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { auto e = *ei; auto u = source(e, g), v = target(e, g); diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index 147cf161..9c4cc20a 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -23,9 +23,9 @@ using namespace boost; int main(int, char *[]) { - using graph_t = adjacency_list < listS, vecS, directedS, - no_property, property < edge_weight_t, int > >; - using vertex_descriptor = graph_traits < graph_t >::vertex_descriptor; + using graph_t = adjacency_list>; + using vertex_descriptor = graph_traits::vertex_descriptor; using Edge = std::pair; const int num_nodes = 5; @@ -47,7 +47,7 @@ main(int, char *[]) distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g)))); std::cout << "distances and parents:" << std::endl; - graph_traits < graph_t >::vertex_iterator vi, vend; + graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: @@ -63,9 +63,9 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits < graph_t >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - graph_traits < graph_t >::edge_descriptor e = *ei; + graph_traits::edge_descriptor e = *ei; auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 754db2e9..16f80be3 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -15,9 +15,9 @@ namespace boost { - template < typename Graph > - std::pair < typename graph_traits < Graph >::vertex_descriptor, - typename graph_traits < Graph >::degree_size_type > + template + std::pair < typename graph_traits::vertex_descriptor, + typename graph_traits::degree_size_type> min_degree_vertex(Graph & g) { typename graph_traits < Graph >::vertex_descriptor p; @@ -33,12 +33,12 @@ namespace boost return std::make_pair(p, delta); } - template < typename Graph, typename OutputIterator > + template void neighbors(const Graph & g, - typename graph_traits < Graph >::vertex_descriptor u, + typename graph_traits::vertex_descriptor u, OutputIterator result) { - typename graph_traits < Graph >::adjacency_iterator ai, aend; + typename graph_traits::adjacency_iterator ai, aend; for (boost::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) *result++ = *ai; } @@ -52,38 +52,38 @@ namespace boost neighbors(g, *first, result); } - template < typename VertexListGraph, typename OutputIterator > - typename graph_traits < VertexListGraph >::degree_size_type + template + typename graph_traits::degree_size_type edge_connectivity(VertexListGraph & g, OutputIterator disconnecting_set) { using vertex_descriptor = typename graph_traits < VertexListGraph >::vertex_descriptor; using degree_size_type = typename graph_traits < VertexListGraph >::degree_size_type; - using Color = color_traits < default_color_type >; + using Color = color_traits; using edge_descriptor = typename adjacency_list_traits < vecS, vecS, directedS >::edge_descriptor; using FlowGraph = adjacency_list < vecS, vecS, directedS, no_property, property < edge_capacity_t, degree_size_type, property < edge_residual_capacity_t, degree_size_type, - property < edge_reverse_t, edge_descriptor > > > >; + property>>>; vertex_descriptor u, v, p, k; edge_descriptor e1, e2; bool inserted; - typename graph_traits < VertexListGraph >::vertex_iterator vi, vi_end; + typename graph_traits::vertex_iterator vi, vi_end; degree_size_type delta, alpha_star, alpha_S_k; - std::set < vertex_descriptor > S, neighbor_S; - std::vector < vertex_descriptor > S_star, nonneighbor_S; - std::vector < default_color_type > color(num_vertices(g)); - std::vector < edge_descriptor > pred(num_vertices(g)); + std::set S, neighbor_S; + std::vector S_star, nonneighbor_S; + std::vector color(num_vertices(g)); + std::vector pred(num_vertices(g)); FlowGraph flow_g(num_vertices(g)); auto cap = get(edge_capacity, flow_g); auto res_cap = get(edge_residual_capacity, flow_g); auto rev_edge = get(edge_reverse, flow_g); - typename graph_traits < VertexListGraph >::edge_iterator ei, ei_end; + typename graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { u = source(*ei, g), v = target(*ei, g); boost::tie(e1, inserted) = add_edge(u, v, flow_g); @@ -125,12 +125,12 @@ namespace boost std::back_inserter(nonneighbor_S)); } - std::vector < bool > in_S_star(num_vertices(g), false); + std::vector in_S_star(num_vertices(g), false); for (const auto& vertex : S_star.begin()) in_S_star[vertex] = true; degree_size_type c = 0; for (const auto& vertex : S_star.begin()) { - typename graph_traits < VertexListGraph >::out_edge_iterator ei, ei_end; + typename graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; @@ -150,8 +150,8 @@ main() GraphvizGraph g; read_graphviz("figs/edge-connectivity.dot", g); - using edge_descriptor = graph_traits < GraphvizGraph >::edge_descriptor; - std::vector < edge_descriptor > disconnecting_set; + using edge_descriptor = graph_traits::edge_descriptor; + std::vector disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); std::cout << "The edge connectivity is " << c << "." << std::endl; diff --git a/example/edge-function.cpp b/example/edge-function.cpp index bcc11db6..c5acf96b 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -36,25 +36,25 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, break; } -template < typename Graph, typename VertexNameMap > void +template void output_adjacent_vertices(std::ostream & out, - typename graph_traits < Graph >::vertex_descriptor u, + typename graph_traits::vertex_descriptor u, const Graph & g, VertexNameMap name_map) { - typename graph_traits < Graph >::adjacency_iterator vi, vi_end; + typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } -template < typename NameMap > class name_equals_t { +template class name_equals_t { public: name_equals_t(const std::string & n, NameMap map) : m_name(n), m_name_map(map) { } - template < typename Vertex > bool operator()(Vertex u) const + template bool operator()(Vertex u) const { return get(m_name_map, u) == m_name; } @@ -64,11 +64,11 @@ template < typename NameMap > class name_equals_t { }; // object generator function -template < typename NameMap > - inline name_equals_t < NameMap > +template + inline name_equals_t name_equals(const std::string & str, NameMap name) { - return name_equals_t < NameMap > (str, name); + return name_equals_t (str, name); } @@ -78,7 +78,7 @@ main() using graph_type = adjacency_list // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -98,28 +98,28 @@ main() } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = + property_map::type name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits < graph_type >::vertex_descriptor yow, zag, bar; + graph_traits::vertex_descriptor yow, zag, bar; // Get vertex name property map from the graph auto name = get(vertex_name, g); // Get iterators for the vertex set - graph_traits < graph_type >::vertex_iterator i, end; + graph_traits::vertex_iterator i, end; boost::tie(i, end) = vertices(g); // Find yow.h - typedef property_map < graph_type, vertex_name_t >::type name_map_t; + using name_map_t = property_map::type; name_equals_t predicate1("yow.h", name); yow = *std::find_if(i, end, predicate1); // Find zag.o - name_equals_t < name_map_t > predicate2("zag.o", name); + name_equals_t predicate2("zag.o", name); zag = *std::find_if(i, end, predicate2); // Find bar.o - name_equals_t < name_map_t > predicate3("bar.o", name); + name_equals_t predicate3("bar.o", name); bar = *std::find_if(i, end, predicate3); - graph_traits < graph_type >::edge_descriptor e1, e2; + graph_traits::edge_descriptor e1, e2; bool exists; // Get the edge connecting yow.h to zag.o diff --git a/example/edge-iter-constructor.cpp b/example/edge-iter-constructor.cpp index 2642ef16..582e3080 100644 --- a/example/edge-iter-constructor.cpp +++ b/example/edge-iter-constructor.cpp @@ -12,8 +12,8 @@ using namespace boost; -template < typename T > - std::istream & operator >> (std::istream & in, std::pair < T, T > &p) { +template + std::istream & operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return in; } @@ -29,7 +29,7 @@ main() >; std::ifstream file_in("makefile-dependencies.dat"); - using size_type = graph_traits < graph_type >::vertices_size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices @@ -37,7 +37,7 @@ main() g(n_vertices); // create graph with n vertices // Read in edges - graph_traits < graph_type >::vertices_size_type u, v; + graph_traits::vertices_size_type u, v; while (file_in >> u) if (file_in >> v) add_edge(u, v, g); diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index 04ddc1ec..ea0fbfb6 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -47,12 +47,12 @@ main() { using namespace boost; - using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Traits = adjacency_list_traits; using Graph = adjacency_list < listS, vecS, directedS, - property < vertex_name_t, std::string >, + property, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > >; + property>>>; Graph g; @@ -76,8 +76,8 @@ main() std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits < Graph >::vertex_iterator u_iter, u_end; - graph_traits < Graph >::out_edge_iterator ei, e_end; + graph_traits::vertex_iterator u_iter, u_end; + graph_traits::out_edge_iterator ei, e_end; for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index df4b554d..0085f17b 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -68,7 +68,7 @@ int main(int , char* []) { using Graph = boost::adjacency_list >; + boost::property>; const int num_vertices = 9; Graph G(num_vertices); diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index dde54187..7ee6de7d 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -21,12 +21,12 @@ using namespace boost; int main() { - using ICmp = indirect_cmp >; + using ICmp = indirect_cmp>; int i; boost::mt19937 gen; for (int N = 2; N < 200; ++N) { uniform_int<> distrib(0, N-1); - variate_generator > rand_gen(gen, distrib); + variate_generator> rand_gen(gen, distrib); for (std::size_t t = 0; t < 10; ++t) { std::vector v, w(N); diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 1af58223..6375663a 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -29,18 +29,18 @@ int main() { using namespace boost; - using graph_t = adjacency_list < vecS, vecS, bidirectionalS, - property < vertex_name_t, char > >; + using graph_t = adjacency_list>; enum { a, b, c, d, e, f, g, N }; graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits < graph_t >::vertex_iterator v, v_end; + graph_traits::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - using E = std::pair < int, int >; + using E = std::pair; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/filtered_graph.cpp b/example/filtered_graph.cpp index df831008..964901cd 100644 --- a/example/filtered_graph.cpp +++ b/example/filtered_graph.cpp @@ -42,7 +42,7 @@ int main() using namespace boost; using Graph = adjacency_list >; + no_property, property>; using EdgeWeightMap = property_map::type; enum { A, B, C, D, E, N }; @@ -56,7 +56,7 @@ int main() add_edge(E, C, 0, g); positive_edge_weight filter(get(edge_weight, g)); - filtered_graph > + filtered_graph> fg(g, filter); std::cout << "filtered edge set: "; diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index ccbcece8..4a92688b 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -66,7 +66,7 @@ int main() << "-> " << name[target(*f, g)] << "\n"; positive_edge_weight filter(weight); - using FGraph = filtered_graph >; + using FGraph = filtered_graph>; FGraph fg(g, filter); std::cout << "filtered edge_range(C,D)\n"; diff --git a/example/filtered_vec_as_graph.cpp b/example/filtered_vec_as_graph.cpp index 4a59a1d3..f4a31cc2 100644 --- a/example/filtered_vec_as_graph.cpp +++ b/example/filtered_vec_as_graph.cpp @@ -40,7 +40,7 @@ int main() enum { A, B, C, D, E }; const char* name = "ABCDE"; - using Graph = std::vector < std::list < int > >; + using Graph = std::vector>; Graph g = { {B, C}, //A {}, //B diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 0a4cf004..83a79cb8 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -41,7 +41,7 @@ using topology_type = boost::rectangle_topology<>; using point_type = topology_type::point_type; using Graph = adjacency_list >; + property>; using Vertex = graph_traits::vertex_descriptor; diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index b660536b..7fc58506 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -78,7 +78,7 @@ struct ordered_set_by_nameS { }; namespace boost { template struct container_gen { - using type = std::set >; + using type = std::set>; }; template <> struct parallel_edge_traits { diff --git a/example/graph-assoc-types.cpp b/example/graph-assoc-types.cpp index 48b38956..abd7ffda 100644 --- a/example/graph-assoc-types.cpp +++ b/example/graph-assoc-types.cpp @@ -10,26 +10,26 @@ using namespace boost; -template < typename Graph > void +template void generic_foo(Graph & g) { // Access descriptor types - using Vertex = typename graph_traits < Graph >::vertex_descriptor; - using Edge = typename graph_traits < Graph >::edge_descriptor; + using Vertex = typename graph_traits::vertex_descriptor; + using Edge = typename graph_traits::edge_descriptor; // Access category types - using Dir = typename graph_traits < Graph >::directed_category; - using Par = typename graph_traits < Graph >::edge_parallel_category; + using Dir = typename graph_traits::directed_category; + using Par = typename graph_traits::edge_parallel_category; // Access iterator types... // Access size types... // Now do something useful... } -template < typename Graph > void +template void generic_bar(Graph & g) { // Declare some vertex and edge descriptor variables - typename graph_traits < Graph >::vertex_descriptor u = vertex(0,g), v = vertex(1,g); - typename graph_traits < Graph >::edge_descriptor e1, e2; + typename graph_traits::vertex_descriptor u = vertex(0,g), v = vertex(1,g); + typename graph_traits::edge_descriptor e1, e2; // Set u and e1 to valid descriptors... v = u; // Make v a handle to the same vertex as u. e2 = e1; // Make e2 a handle to the same edge as e1. @@ -40,43 +40,43 @@ generic_bar(Graph & g) } // This version of foo gets called when g is directed -template < typename Graph > void +template void foo_dispatch(Graph & g, boost::directed_tag) { //... } // This version of foo gets called when g is undirected -template < typename Graph > void +template void foo_dispatch(Graph & g, boost::undirected_tag) { //... } -template < typename Graph > void +template void foo(Graph & g) { - using Cat = typename boost::graph_traits < Graph >::directed_category; + using Cat = typename boost::graph_traits::directed_category; foo_dispatch(g, Cat()); } -template < typename Digraph > void +template void foo(Digraph & digraph, - typename graph_traits < Digraph >::vertex_descriptor u, - typename graph_traits < Digraph >::vertex_descriptor v) + typename graph_traits::vertex_descriptor u, + typename graph_traits::vertex_descriptor v) { - using edge_t = typename graph_traits < Digraph >::edge_descriptor; + using edge_t = typename graph_traits::edge_descriptor; std::pair e1, e2; e1 = edge(u, v, digraph); e2 = edge(v, u, digraph); assert(e1.first != e2.first); } -template < typename Undigraph > void +template void bar(Undigraph & undigraph, - typename graph_traits < Undigraph >::vertex_descriptor u, - typename graph_traits < Undigraph >::vertex_descriptor v) + typename graph_traits::vertex_descriptor u, + typename graph_traits::vertex_descriptor v) { - using edge_t = typename graph_traits < Undigraph >::edge_descriptor; + using edge_t = typename graph_traits::edge_descriptor; std::pair e1, e2; e1 = edge(u, v, undigraph); e2 = edge(v, u, undigraph); @@ -88,7 +88,7 @@ int main() { - boost::adjacency_list < vecS, vecS, directedS > g(2); + boost::adjacency_list g(2); add_edge(0, 1, g); add_edge(1, 0, g); generic_foo(g); @@ -96,7 +96,7 @@ main() foo(g); foo(g, vertex(0, g), vertex(1, g)); - boost::adjacency_list < vecS, vecS, undirectedS > ug(2); + boost::adjacency_list ug(2); add_edge(0, 1, g); bar(ug, vertex(0, g), vertex(1, g)); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index 4200334f..a19ccd4c 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -16,19 +16,19 @@ int main() { using namespace boost; - using graph_t = adjacency_list < listS, vecS, directedS, - property < vertex_name_t, std::string > >; + using graph_t = adjacency_list>; graph_t g(3); const char *vertex_names[] = { "Kubrick", "Clark", "Hal" }; int i = 0; - graph_property_iter_range < graph_t, vertex_name_t >::iterator v, v_end; + graph_property_iter_range::iterator v, v_end; for (boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); v != v_end; ++v, ++i) *v = vertex_names[i]; boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); - std::copy(v, v_end, std::ostream_iterator < std::string > (std::cout, " ")); + std::copy(v, v_end, std::ostream_iterator (std::cout, " ")); std::cout << std::endl; return 0; } diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index 8db6992c..42a57cee 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -31,17 +31,17 @@ struct vertex_label_t { using kind = vertex_property_tag; }; int main() { // Vertex properties - using vertex_p = property < vertex_name_t, string, - property < vertex_label_t, string, - property < vertex_root_t, int > > >; + using vertex_p = property>>; // Edge properties - using edge_p = property < edge_name_t, string >; + using edge_p = property; // Graph properties - using graph_p = property < graph_name_t, string, - property < graph_identifier_t, string > >; + using graph_p = property>; // adjacency_list-based type - using graph_t = adjacency_list < vecS, vecS, directedS, - vertex_p, edge_p, graph_p >; + using graph_t = adjacency_list; // Construct an empty graph and prepare the dynamic_property_maps. graph_t graph(0); diff --git a/example/graph.cpp b/example/graph.cpp index b9181872..04900964 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -21,7 +21,7 @@ using VertexProperty = property > > > >; + property>>>>; using EdgeProperty = property; using Graph = adjacency_list; diff --git a/example/graph_as_tree.cpp b/example/graph_as_tree.cpp index fa115ca0..2dcf62ca 100644 --- a/example/graph_as_tree.cpp +++ b/example/graph_as_tree.cpp @@ -34,7 +34,7 @@ int main() { using namespace boost; using graph_t = adjacency_list >; + property>; using vertex_t = graph_traits::vertex_descriptor; graph_t g; diff --git a/example/graph_property.cpp b/example/graph_property.cpp index 6ba2859d..a35c0326 100644 --- a/example/graph_property.cpp +++ b/example/graph_property.cpp @@ -17,7 +17,7 @@ main() using graph_t = adjacency_list, - property >; + property>; graph_t g; get_property(g, graph_name) = "graph"; diff --git a/example/graphviz.cpp b/example/graphviz.cpp index 33735c01..d83e8b78 100644 --- a/example/graphviz.cpp +++ b/example/graphviz.cpp @@ -16,11 +16,11 @@ using namespace boost; using Digraph = boost::adjacency_list, - property >; + property>; using Graph = boost::adjacency_list, - property >; + property>; void test_graph_read_write(const std::string& filename) { diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index 22326800..ba5db765 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -91,13 +91,13 @@ struct edge_weight_map; // ReadablePropertyGraph associated types namespace boost { template<> - struct property_map< ring_graph, edge_weight_t > { + struct property_map { using type = edge_weight_map; using const_type = edge_weight_map; }; template<> - struct property_map< const ring_graph, edge_weight_t > { + struct property_map { using type = edge_weight_map; using const_type = edge_weight_map; }; diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index 6cf23012..0b1fd09c 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -23,7 +23,7 @@ using namespace boost; template > + typename Divides = divides> struct inclusive_average { using distance_type = DistanceType; diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 229b6f6e..bdb870cd 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -79,7 +79,7 @@ main() // Create the graph, and specify that we will use std::string to // store the first name's. using MyGraphType = adjacency_list >; + property>; using Pair = pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index 78bd3994..84e12b90 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -24,7 +24,7 @@ main() const int n = 12; using graph_t = adjacency_list >; + property>; graph_t g1(n), g2(n); std::vector::vertex_descriptor> v1(n), v2(n); diff --git a/example/iteration_macros.cpp b/example/iteration_macros.cpp index a0524221..773bda2a 100644 --- a/example/iteration_macros.cpp +++ b/example/iteration_macros.cpp @@ -29,8 +29,8 @@ int main() add_edge(Rick, Margaret, g); add_edge(John, Benjamin, g); - graph_traits >::vertex_iterator i, end; - graph_traits >::adjacency_iterator ai, a_end; + graph_traits>::vertex_iterator i, end; + graph_traits>::adjacency_iterator ai, a_end; auto index_map = get(vertex_index, g); BGL_FORALL_VERTICES(i, g, adjacency_list<>) { diff --git a/example/iterator-property-map-eg.cpp b/example/iterator-property-map-eg.cpp index 9257af4e..3113429e 100644 --- a/example/iterator-property-map-eg.cpp +++ b/example/iterator-property-map-eg.cpp @@ -13,7 +13,7 @@ main() { using namespace boost; double x[] = { 0.2, 4.5, 3.2 }; - iterator_property_map < double *, identity_property_map, double, double& > pmap(x); + iterator_property_map pmap(x); std::cout << "x[1] = " << get(pmap, 1) << std::endl; put(pmap, 0, 1.7); std::cout << "x[0] = " << pmap[0] << std::endl; diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index d77d4ed1..44b855d0 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -20,9 +20,9 @@ main() { using namespace boost; using Graph = adjacency_list > >; + property>>; const int V = 6; - using Edge = std::pair < int, int >; + using Edge = std::pair; Edge edge_array[] = { Edge(0, 1), Edge(0, 2), Edge(0, 3), Edge(0, 4), Edge(0, 5), Edge(1, 2), Edge(1, 5), Edge(1, 3), Edge(2, 4), Edge(2, 5), @@ -42,11 +42,11 @@ main() int weights[] = { 0, 0, 0, 0, 0, 3, -4, 8, 1, 7, 4, -5, 2, 6 }; int *wp = weights; - graph_traits < Graph >::edge_iterator e, e_end; + graph_traits::edge_iterator e, e_end; for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) w[*e] = *wp++; - std::vector < int >d(V, (std::numeric_limits < int >::max)()); + std::vectord(V, (std::numeric_limits < int>::max)()); int D[V][V]; johnson_all_pairs_shortest_paths(g, D, distance_map(&d[0])); @@ -72,7 +72,7 @@ main() << "ratio=\"fill\"\n" << "edge[style=\"bold\"]\n" << "node[shape=\"circle\"]\n"; - graph_traits < Graph >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) fout << source(*ei, g) << " -> " << target(*ei, g) << "[label=" << get(edge_weight, g)[*ei] << "]\n"; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 1da9617a..1ac22101 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -36,11 +36,11 @@ class bacon_number_recorder : public default_bfs_visitor }; // Convenience function -template < typename DistanceMap > +template bacon_number_recorder record_bacon_number(DistanceMap d) { - return bacon_number_recorder < DistanceMap > (d); + return bacon_number_recorder (d); } @@ -53,19 +53,20 @@ main() return EXIT_FAILURE; } - using Graph = adjacency_list < vecS, vecS, undirectedS, property < vertex_name_t, - std::string >, property < edge_name_t, std::string > >; + using Graph = adjacency_list , + property>; Graph g; auto actor_name = get(vertex_name, g); auto connecting_movie = get(edge_name, g); - using Vertex = graph_traits < Graph >::vertex_descriptor; - using NameVertexMap = std::map < std::string, Vertex >; + using Vertex = graph_traits::vertex_descriptor; + using NameVertexMap = std::map; NameVertexMap actors; for (std::string line; std::getline(datafile, line);) { - char_delimiters_separator < char >sep(false, "", ";"); + char_delimiters_separator sep(false, "", ";"); tokenizer <> line_toks(line, sep); tokenizer <>::iterator i = line_toks.begin(); std::string actors_name = *i++; @@ -90,14 +91,14 @@ main() } else v = pos->second; - graph_traits < Graph >::edge_descriptor e; + graph_traits::edge_descriptor e; boost::tie(e, inserted) = add_edge(u, v, g); if (inserted) connecting_movie[e] = movie_name; } - std::vector < int >bacon_number(num_vertices(g)); + std::vectorbacon_number(num_vertices(g)); Vertex src = actors["Kevin Bacon"]; bacon_number[src] = 0; @@ -105,7 +106,7 @@ main() breadth_first_search(g, src, visitor(record_bacon_number(&bacon_number[0]))); - graph_traits < Graph >::vertex_iterator i, end; + graph_traits::vertex_iterator i, end; for (boost::tie(i, end) = vertices(g); i != end; ++i) { std::cout << actor_name[*i] << " has a Bacon number of " << bacon_number[*i] << std::endl; diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 0f31b05b..06349ab1 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -35,7 +35,7 @@ int main(int , char* []) using namespace std; using Graph = adjacency_list > >; + property>>; using Vertex = graph_traits::vertex_descriptor; using size_type = graph_traits::vertices_size_type; diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index e525d736..68e9becc 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -17,7 +17,7 @@ using namespace boost; -using Position = std::pair < int, int >; +using Position = std::pair; Position knight_jumps[8] = { Position(2, -1), @@ -144,21 +144,21 @@ adjacent_vertices(knights_tour_graph::vertex_descriptor v, struct compare_first { - template < typename P > bool operator() (const P & x, const P & y) + template bool operator() (const P & x, const P & y) { return x.first < y.first; } }; -template < typename Graph, typename TimePropertyMap > +template bool backtracking_search(Graph & g, typename graph_traits < Graph >::vertex_descriptor src, TimePropertyMap time_map) { - using Vertex = typename graph_traits < Graph >::vertex_descriptor; - using P = std::pair < int, Vertex >; - std::stack < P > S; + using Vertex = typename graph_traits::vertex_descriptor; + using P = std::pair; + std::stack

S; int time_stamp = 0; S.push(std::make_pair(time_stamp, src)); @@ -171,7 +171,7 @@ template < typename Graph, typename TimePropertyMap > return true; bool deadend = true; - typename graph_traits < Graph >::adjacency_iterator i, end; + typename graph_traits::adjacency_iterator i, end; for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { S.push(std::make_pair(time_stamp + 1, *i)); @@ -193,25 +193,25 @@ template < typename Graph, typename TimePropertyMap > return false; } -template < typename Vertex, typename Graph, typename TimePropertyMap > int +template int number_of_successors(Vertex x, Graph & g, TimePropertyMap time_map) { int s_x = 0; - typename graph_traits < Graph >::adjacency_iterator i, end; + typename graph_traits::adjacency_iterator i, end; for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) ++s_x; return s_x; } -template < typename Graph, typename TimePropertyMap > +template bool warnsdorff(Graph & g, - typename graph_traits < Graph >::vertex_descriptor src, + typename graph_traits::vertex_descriptor src, TimePropertyMap time_map) { - using Vertex = typename graph_traits < Graph >::vertex_descriptor; - using P = std::pair < int, Vertex >; - std::stack < P > S; + using Vertex = typename graph_traits::vertex_descriptor; + using P = std::pair; + std::stack

S; int time_stamp = 0; S.push(std::make_pair(time_stamp, src)); @@ -224,8 +224,8 @@ template < typename Graph, typename TimePropertyMap > return true; // Put adjacent vertices into a local priority queue - std::priority_queue < P, std::vector < P >, compare_first > Q; - typename graph_traits < Graph >::adjacency_iterator i, end; + std::priority_queue, compare_first> Q; + typename graph_traits::adjacency_iterator i, end; int num_succ; for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index b3b1bf44..e7b49602 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -14,9 +14,9 @@ int main() { using namespace boost; - using Graph = adjacency_list < vecS, vecS, undirectedS, - no_property, property < edge_weight_t, int > >; - using Edge = graph_traits < Graph >::edge_descriptor; + using Graph = adjacency_list>; + using Edge = graph_traits::edge_descriptor; using E = std::pair; const int num_nodes = 5; @@ -37,7 +37,7 @@ main() Graph g(edge_array, edge_array + num_edges, weights, num_nodes); #endif auto weight = get(edge_weight, g); - std::vector < Edge > spanning_tree; + std::vector spanning_tree; kruskal_minimum_spanning_tree(g, std::back_inserter(spanning_tree)); diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 9fbf7a85..ac9219eb 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -19,19 +19,19 @@ main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - using Graph = adjacency_list < vecS, vecS, undirectedS, no_property, - property < edge_weight_t, int > >; + using Graph = adjacency_list>; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); - graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); - property < edge_weight_t, int >edge_property(weight); + int weight = lexical_cast(edge_attr_map[*ei]["label"]); + property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } - std::vector < graph_traits < Graph >::edge_descriptor > mst; - using size_type = std::vector < graph_traits < Graph >::edge_descriptor >::size_type; + std::vector::edge_descriptor> mst; + using size_type = std::vector::edge_descriptor>::size_type; kruskal_minimum_spanning_tree(g, std::back_inserter(mst)); auto weight = get(edge_weight, g); @@ -40,7 +40,7 @@ main() total_weight += get(weight, edge); std::cout << "total weight: " << total_weight << std::endl; - using Vertex = graph_traits < Graph >::vertex_descriptor; + using Vertex = graph_traits::vertex_descriptor; for (const auto& edge : mst) { auto u = source(edge, g), v = target(edge, g); edge_attr_map[edge(u, v, g_dot).first]["color"] = "black"; diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index b9185a2b..330f9081 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -22,13 +22,10 @@ using namespace boost; int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property, - property - >; + using graph = adjacency_list, + property>; // Create a K_6 (complete graph on 6 vertices), which // contains both Kuratowski subgraphs as minors. @@ -60,7 +57,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is not planar, we just want to // compute the kuratowski subgraph as a side-effect - using kuratowski_edges_t = std::vector< graph_traits::edge_descriptor >; + using kuratowski_edges_t = std::vector::edge_descriptor>; kuratowski_edges_t kuratowski_edges; if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::kuratowski_subgraph = diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index e5777bd7..8b58fe84 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -15,14 +15,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -45,7 +45,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -61,18 +61,18 @@ main() read_graph_file(file_in, name_in, g, name_map); // Create storage for last modified times - std::vector < time_t > last_mod_vec(num_vertices(g)); + std::vector last_mod_vec(num_vertices(g)); // Create nickname for the property map type - using iter_map_t = iterator_property_map < std::vector < time_t >::iterator, - property_map < graph_type, vertex_index_t >::type, time_t, time_t&>; + using iter_map_t = iterator_property_map < std::vector::iterator, + property_map::type, time_t, time_t&>; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); auto name = get(vertex_name, g); struct stat stat_buf; - graph_traits < graph_type >::vertex_descriptor u; - using vertex_iter_t = graph_traits < graph_type >::vertex_iterator; - std::pair < vertex_iter_t, vertex_iter_t > p; + graph_traits::vertex_descriptor u; + using vertex_iter_t = graph_traits::vertex_iterator; + std::pair p; for (p = vertices(g); p.first != p.second; ++p.first) { u = *p.first; if (stat(name[u].c_str(), &stat_buf) != 0) diff --git a/example/leda-concept-check.cpp b/example/leda-concept-check.cpp index 39cf4f78..a0d9f96a 100644 --- a/example/leda-concept-check.cpp +++ b/example/leda-concept-check.cpp @@ -15,8 +15,8 @@ main() using namespace boost; using Graph = leda::GRAPH; BOOST_CONCEPT_ASSERT(( VertexListGraphConcept )); - BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept< Graph> )); - BOOST_CONCEPT_ASSERT(( VertexMutableGraphConcept< Graph> )); + BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); + BOOST_CONCEPT_ASSERT(( VertexMutableGraphConcept )); BOOST_CONCEPT_ASSERT(( EdgeMutableGraphConcept )); return EXIT_SUCCESS; } diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index d9663563..cb181969 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -12,16 +12,16 @@ int main() { using namespace boost; - using graph_t = leda::GRAPH < std::string, int >; + using graph_t = leda::GRAPH; graph_t g; g.new_node("Philoctetes"); g.new_node("Heracles"); g.new_node("Alcmena"); g.new_node("Eurystheus"); g.new_node("Amphitryon"); - using NodeMap = property_map < graph_t, vertex_all_t >::type; + using NodeMap = property_map::type; auto node_name_map = get(vertex_all, g); - graph_traits < graph_t >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << node_name_map[*vi] << std::endl; return EXIT_SUCCESS; diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 3c9f345f..83e64523 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -20,13 +20,13 @@ using namespace boost; -template < typename OutputIterator > +template class back_edge_recorder : public default_dfs_visitor { public: back_edge_recorder(OutputIterator out):m_out(out) { } - template < typename Edge, typename Graph > + template void back_edge(Edge e, const Graph &) { *m_out++ = e; @@ -36,61 +36,61 @@ class back_edge_recorder : public default_dfs_visitor }; // object generator function -template < typename OutputIterator > -back_edge_recorder < OutputIterator > +template +back_edge_recorder make_back_edge_recorder(OutputIterator out) { - return back_edge_recorder < OutputIterator > (out); + return back_edge_recorder (out); } -template < typename Graph, typename Loops > void -find_loops(typename graph_traits < Graph >::vertex_descriptor entry, +template void +find_loops(typename graph_traits::vertex_descriptor entry, const Graph & g, Loops & loops) // A container of sets of vertices { BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); - using Edge = typename graph_traits < Graph >::edge_descriptor; - std::vector < Edge > back_edges; - std::vector < default_color_type > color_map(num_vertices(g)); + using Edge = typename graph_traits::edge_descriptor; + std::vector back_edges; + std::vector color_map(num_vertices(g)); depth_first_visit(g, entry, make_back_edge_recorder(std::back_inserter(back_edges)), make_iterator_property_map(color_map.begin(), get(vertex_index, g), color_map[0])); - for (typename std::vector < Edge >::size_type i = 0; i < back_edges.size(); ++i) { + for (typename std::vector::size_type i = 0; i < back_edges.size(); ++i) { typename Loops::value_type x; loops.emplace_back(x); compute_loop_extent(back_edges[i], g, loops.back()); } } -template < typename Graph, typename Set > void +template void compute_loop_extent(typename graph_traits < Graph >::edge_descriptor back_edge, const Graph & g, Set & loop_set) { BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); - using Vertex = typename graph_traits < Graph >::vertex_descriptor; - using Color = color_traits < default_color_type >; + using Vertex = typename graph_traits::vertex_descriptor; + using Color = color_traits; Vertex loop_head, loop_tail; loop_tail = source(back_edge, g); loop_head = target(back_edge, g); - std::vector < default_color_type > + std::vector reachable_from_head(num_vertices(g), Color::white()); default_color_type c; depth_first_visit(g, loop_head, default_dfs_visitor(), make_iterator_property_map(reachable_from_head.begin(), get(vertex_index, g), c)); - std::vector < default_color_type > reachable_to_tail(num_vertices(g)); - reverse_graph < Graph > reverse_g(g); + std::vector reachable_to_tail(num_vertices(g)); + reverse_graph reverse_g(g); depth_first_visit(reverse_g, loop_tail, default_dfs_visitor(), make_iterator_property_map(reachable_to_tail.begin(), get(vertex_index, g), c)); - typename graph_traits < Graph >::vertex_iterator vi, vi_end; + typename graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (reachable_from_head[*vi] != Color::white() && reachable_to_tail[*vi] != Color::white()) @@ -111,7 +111,7 @@ main(int argc, char *argv[]) using Graph = adjacency_list < vecS, vecS, bidirectionalS, GraphvizVertexProperty, GraphvizEdgeProperty, GraphvizGraphProperty >; - using Vertex = graph_traits < Graph >::vertex_descriptor; + using Vertex = graph_traits::vertex_descriptor; Graph g; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -121,8 +121,8 @@ main(int argc, char *argv[]) copy_graph(g_in, g); - using set_t = std::set < Vertex >; - using list_of_sets_t = std::list < set_t >; + using set_t = std::set; + using list_of_sets_t = std::list; list_of_sets_t loops; auto entry = *vertices(g).first; @@ -130,10 +130,10 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); auto eattr_map = get(edge_attribute, g); - graph_traits < Graph >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (auto i = loops.begin(); i != loops.end(); ++i) { - std::vector < bool > in_loop(num_vertices(g), false); + std::vector in_loop(num_vertices(g), false); for (auto j = (*i).begin(); j != (*i).end(); ++j) { vattr_map[*j]["color"] = "gray"; in_loop[*j] = true; diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index 28a69264..34757850 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -23,13 +23,10 @@ using namespace boost; int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property, - property - >; + using graph = adjacency_list, + property>; graph g(11); add_edge(0,1,g); @@ -55,7 +52,7 @@ int main(int argc, char** argv) //Test for planarity; compute the planar embedding as a side-effect - using vec_t = std::vector< graph_traits::edge_descriptor >; + using vec_t = std::vector::edge_descriptor>; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = @@ -66,7 +63,7 @@ int main(int argc, char** argv) else std::cout << "Input graph is not planar" << std::endl; - using component_storage_t = std::vector< graph_traits::edges_size_type >; + using component_storage_t = std::vector::edges_size_type>; using component_map_t = iterator_property_map < component_storage_t::iterator, property_map::type diff --git a/example/make_connected.cpp b/example/make_connected.cpp index 4cd44c39..48f1d75a 100644 --- a/example/make_connected.cpp +++ b/example/make_connected.cpp @@ -22,12 +22,9 @@ using namespace boost; int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property - >; + using graph = adjacency_list>; graph g(11); add_edge(0,1,g); @@ -39,7 +36,7 @@ int main(int argc, char** argv) add_edge(9,10,g); add_edge(10,8,g); - std::vector< graph_traits::vertices_size_type > + std::vector::vertices_size_type> component(num_vertices(g)); std::cout << "Before calling make_connected, the graph has " diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index 58cc5fe9..b0439568 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -43,13 +43,10 @@ struct face_counter : public planar_face_traversal_visitor int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property, - property - >; + using graph = adjacency_list, + property>; // Create the graph - a straight line graph g(10); @@ -78,7 +75,7 @@ int main(int argc, char** argv) //Test for planarity; compute the planar embedding as a side-effect - using vec_t = std::vector< graph_traits::edge_descriptor >; + using vec_t = std::vector::edge_descriptor>; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = diff --git a/example/max_flow.cpp b/example/max_flow.cpp index ad1fee84..9c999c3e 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -54,7 +54,7 @@ main() property, property > > + property>> >; Graph g; diff --git a/example/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index bdfab55d..0b18365b 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -73,8 +73,8 @@ int main (int argc, char *argv[]) { // a vertex index map; it will be implicit. using Graph = adjacency_list >, - property >; + property>, + property>; // Test maximum and unique variants on known graphs Graph graph_simple1, graph_simple2; diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index f1168b1b..966c82cb 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -43,7 +43,7 @@ main(int , char* []) using namespace boost; using Graph = adjacency_list >; + no_property, property>; using Vertex = graph_traits::vertex_descriptor; using E = std::pair; diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 19a98d77..4868c611 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -195,7 +195,7 @@ int main() { adjacency_list > g; + no_property, property> g; modify_demo(g); return 0; diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index e577c01d..9eadf8af 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -48,13 +48,13 @@ struct ordered_set_by_nameS { }; namespace boost { template struct container_gen { - using type = std::multiset >; + using type = std::multiset>; }; } #else struct ordered_set_by_nameS { template - struct bind_ { using } = std::multiset > type;; + struct bind_ { using } = std::multiset> type;; }; namespace boost { template <> struct container_selector { diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index ed7109ea..412e0c7e 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -23,8 +23,8 @@ main() adjacency_list, property >, - property >; + property>, + property>; g_dot_type g_dot; dynamic_properties dp(ignore_other_properties); @@ -37,28 +37,28 @@ main() read_graphviz(infile, g_dot, dp); } - using Graph = adjacency_list < vecS, vecS, directedS, no_property, - property < edge_weight_t, int > >; - using vertex_descriptor = graph_traits < Graph >::vertex_descriptor; + using Graph = adjacency_list>; + using vertex_descriptor = graph_traits::vertex_descriptor; Graph g(num_vertices(g_dot)); - graph_traits < g_dot_type >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { auto weight = get(edge_weight, g_dot, *ei); - property < edge_weight_t, int >edge_property(weight); + property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } vertex_descriptor router_six; - graph_traits < g_dot_type >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) if ("RT6" == get(vertex_name, g_dot, *vi)) { router_six = *vi; break; } - std::vector < vertex_descriptor > parent(num_vertices(g)); + std::vector parent(num_vertices(g)); // All vertices start out as there own parent - using size_type = graph_traits < Graph >::vertices_size_type; + using size_type = graph_traits::vertices_size_type; for (size_type p = 0; p < num_vertices(g); ++p) parent[p] = p; @@ -74,7 +74,7 @@ main() dijkstra_shortest_paths(g, router_six, predecessor_map(&parent[0])); #endif - graph_traits < g_dot_type >::edge_descriptor e; + graph_traits::edge_descriptor e; for (size_type i = 0; i < num_vertices(g); ++i) if (parent[i] != i) { e = edge(parent[i], i, g_dot).first; @@ -94,7 +94,7 @@ main() rtable << get(vertex_name, g_dot, *vi) << " "; vertex_descriptor v = *vi, child; int path_cost = 0; - property_map < Graph, edge_weight_t >::type + property_map::type weight_map = get(edge_weight, g); do { path_cost += get(weight_map, edge(parent[v], v, g).first); diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index ca8af7e7..b7fbfb08 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -17,8 +17,8 @@ namespace std { - template < typename T > - std::istream & operator >> (std::istream & in, std::pair < T, T > &p) + template + std::istream & operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return in; @@ -33,31 +33,31 @@ namespace boost using namespace boost; -using file_dep_graph2 = adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph2 = adjacency_list > > >, + property>>>, // an edge property - property < edge_weight_t, float > >; + property>; using vertex_t = graph_traits::vertex_descriptor; using edge_t = graph_traits::edge_descriptor; -template < typename Graph, typename ColorMap, typename Visitor > void +template void dfs_v2(const Graph & g, - typename graph_traits < Graph >::vertex_descriptor u, + typename graph_traits::vertex_descriptor u, ColorMap color, Visitor vis) { - using color_type = typename property_traits < ColorMap >::value_type; - using ColorT = color_traits < color_type >; + using color_type = typename property_traits::value_type; + using ColorT = color_traits; color[u] = ColorT::gray(); vis.discover_vertex(u, g); - typename graph_traits < Graph >::out_edge_iterator ei, ei_end; + typename graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) if (color[target(*ei, g)] == ColorT::white()) { vis.tree_edge(*ei, g); @@ -70,12 +70,12 @@ dfs_v2(const Graph & g, vis.finish_vertex(u, g); } -template < typename Graph, typename Visitor, typename ColorMap > void +template void generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) { using ColorValue = typename property_traits ::value_type; - using ColorT = color_traits < ColorValue > ; - typename graph_traits < Graph >::vertex_iterator vi, vi_end; + using ColorT = color_traits ; + typename graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) color[*vi] = ColorT::white(); for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) @@ -84,15 +84,15 @@ generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) } -template < typename OutputIterator > +template struct topo_visitor: public default_dfs_visitor { topo_visitor(OutputIterator & order): topo_order(order) { } - template < typename Graph > void - finish_vertex(typename graph_traits < Graph >::vertex_descriptor u, + template void + finish_vertex(typename graph_traits::vertex_descriptor u, const Graph &) { *topo_order++ = u; @@ -100,29 +100,29 @@ struct topo_visitor: public default_dfs_visitor OutputIterator & topo_order; }; -template < typename Graph, typename OutputIterator, typename ColorMap > void +template void topo_sort(const Graph & g, OutputIterator topo_order, ColorMap color) { - topo_visitor < OutputIterator > vis(topo_order); + topo_visitor vis(topo_order); generic_dfs_v2(g, vis, color); } -using name_map_t = property_map < file_dep_graph2, vertex_name_t >::type; -using compile_cost_map_t = property_map < file_dep_graph2, vertex_compile_cost_t >::type; -using distance_map_t = property_map < file_dep_graph2, vertex_distance_t >::type; -using color_map_t = property_map < file_dep_graph2, vertex_color_t >::type; +using name_map_t = property_map::type; +using compile_cost_map_t = property_map::type; +using distance_map_t = property_map::type; +using color_map_t = property_map::type; int main() { std::ifstream file_in("makefile-dependencies.dat"); - using size_type = graph_traits < file_dep_graph2 >::vertices_size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator < std::pair < size_type, - size_type > >input_begin(file_in), input_end; + size_type >> input_begin(file_in), input_end; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor file_dep_graph2 g; @@ -155,18 +155,18 @@ main() { std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); - graph_traits < file_dep_graph2 >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; } } - std::vector < vertex_t > topo_order(num_vertices(g)); + std::vector topo_order(num_vertices(g)); topo_sort(g, topo_order.rbegin(), color_map); - graph_traits < file_dep_graph2 >::vertex_iterator i, i_end; - graph_traits < file_dep_graph2 >::adjacency_iterator vi, vi_end; + graph_traits::vertex_iterator i, i_end; + graph_traits::adjacency_iterator vi, vi_end; // find source vertices with zero in-degree by marking all vertices with incoming edges for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) @@ -182,7 +182,7 @@ main() else distance_map[*i] = 0; - std::vector < vertex_t >::iterator ui; + std::vector::iterator ui; for (ui = topo_order.begin(); ui != topo_order.end(); ++ui) { vertex_t u = * diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index 9df040a5..27ad8715 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -99,7 +99,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - using vec_t = std::vector< graph_traits::edge_descriptor >; + using vec_t = std::vector::edge_descriptor>; std::vector embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = diff --git a/example/prim-example.cpp b/example/prim-example.cpp index bf8d2f22..2a2cc87a 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -14,9 +14,9 @@ int main() { using namespace boost; - using Graph = adjacency_list < vecS, vecS, undirectedS, - property, property < edge_weight_t, int > >; - using E = std::pair < int, int>; + using Graph = adjacency_list, property>; + using E = std::pair; const int num_nodes = 5; const auto edges = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index a870adac..5fe612b9 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -19,14 +19,14 @@ main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - using Graph = adjacency_list < vecS, vecS, undirectedS, no_property, - property < edge_weight_t, int > >; + using Graph = adjacency_list>; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); - graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - auto weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); - property < edge_weight_t, int >edge_property(weight); + auto weight = lexical_cast(edge_attr_map[*ei]["label"]); + property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } @@ -52,7 +52,7 @@ main() if (parent[u] != u) edge_attr_map[edge(parent[u], u, g_dot).first]["color"] = "black"; std::ofstream out("figs/telephone-mst-prim.dot"); - graph_property < GraphvizGraph, graph_edge_attribute_t >::type & + graph_property::type & graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); graph_edge_attr_map["color"] = "gray"; write_graphviz(out, g_dot); diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index d9e5b920..2912042b 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -36,25 +36,25 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, break; } -template < typename Graph, typename VertexNameMap > void +template void output_adjacent_vertices(std::ostream & out, - typename graph_traits < Graph >::vertex_descriptor u, + typename graph_traits::vertex_descriptor u, const Graph & g, VertexNameMap name_map) { - typename graph_traits < Graph >::adjacency_iterator vi, vi_end; + typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } -template < typename NameMap > class name_equals_t { +template class name_equals_t { public: name_equals_t(const std::string & n, NameMap map) : m_name(n), m_name_map(map) { } - template < typename Vertex > bool operator()(Vertex u) const + template bool operator()(Vertex u) const { return get(m_name_map, u) == m_name; } @@ -64,11 +64,11 @@ template < typename NameMap > class name_equals_t { }; // object generator function -template < typename NameMap > - inline name_equals_t < NameMap > +template + inline name_equals_t name_equals(const std::string & str, NameMap name) { - return name_equals_t < NameMap > (str, name); + return name_equals_t (str, name); } @@ -78,7 +78,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -96,11 +96,11 @@ main() return -1; } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = + property_map::type name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits < graph_type >::vertex_iterator i, end; + graph_traits::vertex_iterator i, end; boost::tie(i, end) = vertices(g); i = std::find_if(i, end, name_equals("dax.h", get(vertex_name, g))); output_adjacent_vertices(std::cout, *i, g, get(vertex_name, g)); diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 13129a1d..2074c4a8 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -36,11 +36,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, break; } -template < typename Graph, typename VertexNameMap > void +template void print_dependencies(std::ostream & out, const Graph & g, VertexNameMap name_map) { - typename graph_traits < Graph >::edge_iterator ei, ei_end; + typename graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -$>$ " << get(name_map, target(*ei, g)) << std::endl; @@ -53,7 +53,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -72,7 +72,7 @@ main() } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = + property_map::type name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index d326bc36..c3e38d27 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -36,24 +36,24 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, break; } -template < typename Graph, typename VertexNameMap > void +template void output_in_edges(std::ostream & out, const Graph & g, - typename graph_traits < Graph >::vertex_descriptor v, + typename graph_traits::vertex_descriptor v, VertexNameMap name_map) { - typename graph_traits < Graph >::in_edge_iterator ei, ei_end; + typename graph_traits::in_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } -template < typename NameMap > class name_equals_t { +template class name_equals_t { public: name_equals_t(const std::string & n, NameMap map) : m_name(n), m_name_map(map) { } - template < typename Vertex > bool operator()(Vertex u) const + template bool operator()(Vertex u) const { return get(m_name_map, u) == m_name; } @@ -63,11 +63,11 @@ template < typename NameMap > class name_equals_t { }; // object generator function -template < typename NameMap > - inline name_equals_t < NameMap > +template + inline name_equals_t name_equals(const std::string & str, NameMap name) { - return name_equals_t < NameMap > (str, name); + return name_equals_t (str, name); } @@ -77,7 +77,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector bidirectionalS, // The graph is directed, with both out-edges and in-edges - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -96,11 +96,11 @@ main() } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = + property_map::type name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits < graph_type >::vertex_iterator i, end; + graph_traits::vertex_iterator i, end; boost::tie(i, end) = vertices(g); i = std::find_if(i, end, name_equals("libzigzag.a", get(vertex_name, g))); output_in_edges(std::cout, g, *i, get(vertex_name, g)); diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index 68d23d09..6c331910 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -36,24 +36,24 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, break; } -template < typename Graph, typename VertexNameMap > void +template void output_out_edges(std::ostream & out, const Graph & g, - typename graph_traits < Graph >::vertex_descriptor u, + typename graph_traits::vertex_descriptor u, VertexNameMap name_map) { - typename graph_traits < Graph >::out_edge_iterator ei, ei_end; + typename graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } -template < typename NameMap > class name_equals_t { +template class name_equals_t { public: name_equals_t(const std::string & n, NameMap map) : m_name(n), m_name_map(map) { } - template < typename Vertex > bool operator()(Vertex u) const + template bool operator()(Vertex u) const { return get(m_name_map, u) == m_name; } @@ -63,11 +63,11 @@ template < typename NameMap > class name_equals_t { }; // object generator function -template < typename NameMap > - inline name_equals_t < NameMap > +template + inline name_equals_t name_equals(const std::string & str, NameMap name) { - return name_equals_t < NameMap > (str, name); + return name_equals_t (str, name); } @@ -77,7 +77,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -95,14 +95,14 @@ main() return -1; } // Obtain internal property map from the graph - property_map < graph_type, vertex_name_t >::type name_map = + property_map::type name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits < graph_type >::vertex_iterator i, end; + graph_traits::vertex_iterator i, end; boost::tie(i, end) = vertices(g); - using name_map_t = property_map < graph_type, vertex_name_t >::type; - name_equals_t < name_map_t > predicate("dax.h", get(vertex_name, g)); + using name_map_t = property_map::type; + name_equals_t predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); output_out_edges(std::cout, g, *i, get(vertex_name, g)); diff --git a/example/property-map-traits-eg.cpp b/example/property-map-traits-eg.cpp index d0664042..71bd708f 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -13,10 +13,10 @@ int main() { using namespace boost; - using graph_t = adjacency_list < listS, listS, directedS, - property < vertex_name_t, std::string > >; + using graph_t = adjacency_list>; graph_t g; - graph_traits < graph_t >::vertex_descriptor u = add_vertex(g); + graph_traits::vertex_descriptor u = add_vertex(g); auto name_map = get(vertex_name, g); name_map[u] = "Joe"; std::cout << name_map[u] << std::endl; diff --git a/example/property_iterator.cpp b/example/property_iterator.cpp index 8ba2d306..53eb1bbc 100644 --- a/example/property_iterator.cpp +++ b/example/property_iterator.cpp @@ -24,19 +24,19 @@ struct toto_t { enum { num = 23063}; using kind = vertex_property_tag; }; -using Toto = property< toto_t, double >; +using Toto = property; struct radius_t { enum { num = 23062}; using kind = vertex_property_tag; }; -using Radius = property< radius_t, double, Toto >; +using Radius = property; struct mass_t { enum { num = 23061}; using kind = vertex_property_tag; }; -using Mass = property< mass_t, int, Radius >; +using Mass = property; //====== edge properties diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index c8a955e2..e52362e3 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -46,12 +46,12 @@ int main() { using namespace boost; - using Traits = adjacency_list_traits < vecS, vecS, directedS >; + using Traits = adjacency_list_traits; using Graph = adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, std::string >, + property, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > > > >; + property>>>; Graph g; auto capacity = get(edge_capacity, g); @@ -71,8 +71,8 @@ main() std::cout << "c The total flow:" << std::endl; std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits < Graph >::vertex_iterator u_iter, u_end; - graph_traits < Graph >::out_edge_iterator ei, e_end; + graph_traits::vertex_iterator u_iter, u_end; + graph_traits::out_edge_iterator ei, e_end; for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) diff --git a/example/put-get-helper-eg.cpp b/example/put-get-helper-eg.cpp index fef57a5e..83a511d7 100644 --- a/example/put-get-helper-eg.cpp +++ b/example/put-get-helper-eg.cpp @@ -18,15 +18,15 @@ namespace foo { using namespace boost; - template < class RandomAccessIterator, class IndexMap > + template class iterator_property_map:public boost::put_get_helper < - typename std::iterator_traits < RandomAccessIterator >::reference, - iterator_property_map < RandomAccessIterator, IndexMap > > + typename std::iterator_traits::reference, + iterator_property_map> { public: using key_type = std::ptrdiff_t; - using value_type = typename std::iterator_traits < RandomAccessIterator >::value_type; - using reference = typename std::iterator_traits < RandomAccessIterator >::reference; + using value_type = typename std::iterator_traits::value_type; + using reference = typename std::iterator_traits::reference; using category = boost::lvalue_property_map_tag; iterator_property_map(RandomAccessIterator cc = RandomAccessIterator(), @@ -48,9 +48,9 @@ namespace foo int main() { - using vec_t = std::vector < std::string >; - using pmap_t = foo::iterator_property_map < vec_t::iterator, - boost::identity_property_map >; + using vec_t = std::vector; + using pmap_t = foo::iterator_property_map; using namespace boost; BOOST_CONCEPT_ASSERT(( Mutable_LvaluePropertyMapConcept )); return 0; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 0516ba8a..83e04a5f 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename VertexDescriptor, typename VertexNameMap > void +template void print_vertex_name(VertexDescriptor v, VertexNameMap name_map) { std::cout << get(name_map, v); } -template < typename Graph, typename TransDelayMap, typename VertexNameMap > void -print_trans_delay(typename graph_traits < Graph >::edge_descriptor e, +template void +print_trans_delay(typename graph_traits::edge_descriptor e, const Graph & g, TransDelayMap delay_map, VertexNameMap name_map) { @@ -28,11 +28,11 @@ print_trans_delay(typename graph_traits < Graph >::edge_descriptor e, << get(name_map, target(e, g)) << ") = " << get(delay_map, e); } -template < typename Graph, typename VertexNameMap > void +template void print_vertex_names(const Graph & g, VertexNameMap name_map) { std::cout << "vertices(g) = { "; - using iter_t = typename graph_traits < Graph >::vertex_iterator; + using iter_t = typename graph_traits::vertex_iterator; for (auto p = vertices(g); p.first != p.second; ++p.first) { print_vertex_name(*p.first, name_map); @@ -41,22 +41,22 @@ print_vertex_names(const Graph & g, VertexNameMap name_map) std::cout << "}" << std::endl; } -template < typename Graph, typename TransDelayMap, typename VertexNameMap > void +template void print_trans_delays(const Graph & g, TransDelayMap trans_delay_map, VertexNameMap name_map) { - typename graph_traits < Graph >::edge_iterator first, last; + typename graph_traits::edge_iterator first, last; for (boost::tie(first, last) = edges(g); first != last; ++first) { print_trans_delay(*first, g, trans_delay_map, name_map); std::cout << std::endl; } } -template < typename Graph, typename VertexNameMap, typename TransDelayMap > void +template void build_router_network(Graph & g, VertexNameMap name_map, TransDelayMap delay_map) { - typename graph_traits < Graph >::vertex_descriptor a, b, c, d, e; + typename graph_traits::vertex_descriptor a, b, c, d, e; a = add_vertex(g); name_map[a] = 'a'; b = add_vertex(g); @@ -68,7 +68,7 @@ build_router_network(Graph & g, VertexNameMap name_map, e = add_vertex(g); name_map[e] = 'e'; - typename graph_traits < Graph >::edge_descriptor ed; + typename graph_traits::edge_descriptor ed; bool inserted; boost::tie(ed, inserted) = add_edge(a, b, g); @@ -93,8 +93,8 @@ int main() { using graph_t = adjacency_list < listS, listS, directedS, - property < vertex_name_t, char >, - property < edge_weight_t, double > >; + property, + property>; graph_t g; auto name_map = get(vertex_name, g); diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index b126ea1a..94fcb0e8 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -68,7 +68,7 @@ int main(int,char*[]) { // create an alias for the Graph type using Graph = adjacency_list >; + no_property, property>; // Make convenient labels for the vertices enum { A, B, C, D, E, N }; diff --git a/example/r_c_shortest_paths_example.cpp b/example/r_c_shortest_paths_example.cpp index 89413da5..c20590ce 100644 --- a/example/r_c_shortest_paths_example.cpp +++ b/example/r_c_shortest_paths_example.cpp @@ -243,7 +243,7 @@ int main() std::vector ::edge_descriptor> > + ::edge_descriptor>> opt_solutions; std::vector pareto_opt_rcs_no_rc; @@ -260,7 +260,7 @@ int main() dominance_no_res_cont(), std::allocator >(), + >(), default_r_c_shortest_paths_visitor() ); std::cout << "SPP without resource constraints:" << std::endl; @@ -280,7 +280,7 @@ int main() // spptw std::vector ::edge_descriptor> > + ::edge_descriptor>> opt_solutions_spptw; std::vector pareto_opt_rcs_spptw; @@ -297,7 +297,7 @@ int main() dominance_spptw(), std::allocator >(), + >(), default_r_c_shortest_paths_visitor() ); std::cout << "SPP with time windows:" << std::endl; diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 64181a91..53e83b77 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -24,10 +24,10 @@ main(int argc, char *argv[]) using namespace boost; GraphvizDigraph g; read_graphviz(argv[1], g); - graph_traits < GraphvizDigraph >::vertex_descriptor loop_head = 1; - using Color = color_traits < default_color_type >; + graph_traits::vertex_descriptor loop_head = 1; + using Color = color_traits; - std::vector < default_color_type > + std::vector reachable_from_head(num_vertices(g), Color::white()); default_color_type c; depth_first_visit(g, loop_head, default_dfs_visitor(), @@ -36,7 +36,7 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); - graph_traits < GraphvizDigraph >::vertex_iterator i, i_end; + graph_traits::vertex_iterator i, i_end; for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) if (reachable_from_head[*i] != Color::white()) { vattr_map[*i]["color"] = "gray"; diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index 58da2d9c..9fae501b 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -32,12 +32,12 @@ main(int argc, char *argv[]) Graph g; copy_graph(g_in, g); - graph_traits < GraphvizDigraph >::vertex_descriptor loop_tail = 6; - using Color = color_traits < default_color_type >; + graph_traits::vertex_descriptor loop_tail = 6; + using Color = color_traits; default_color_type c; - std::vector < default_color_type > reachable_to_tail(num_vertices(g)); - reverse_graph < Graph > reverse_g(g); + std::vector reachable_to_tail(num_vertices(g)); + reverse_graph reverse_g(g); depth_first_visit(reverse_g, loop_tail, default_dfs_visitor(), make_iterator_property_map(reachable_to_tail.begin(), get(vertex_index, g), c)); @@ -57,7 +57,7 @@ main(int argc, char *argv[]) } loops_out << "]\n"; } - graph_traits < GraphvizDigraph >::edge_iterator e, e_end; + graph_traits::edge_iterator e, e_end; for (boost::tie(e, e_end) = edges(g_in); e != e_end; ++e) loops_out << source(*e, g) << " -> " << target(*e, g) << ";\n"; loops_out << "}\n"; diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index c1521722..bd7730fb 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -20,12 +20,12 @@ using namespace std; int main() { // Vertex properties - using vertex_p = property < vertex_name_t, std::string, - property < vertex_color_t, float > >; + using vertex_p = property>; // Edge properties - using edge_p = property < edge_weight_t, double >; + using edge_p = property; // Graph properties - using graph_p = property < graph_name_t, std::string >; + using graph_p = property; // adjacency_list-based type using graph_t = adjacency_list < vecS, vecS, directedS, vertex_p, edge_p, graph_p >; diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 062bb823..e11b0f5e 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -61,11 +61,11 @@ struct zero_edge_capacity{ int main() { using namespace boost; - using Traits = adjacency_list_traits < vecS, vecS, directedS >; - using Graph = adjacency_list < vecS, vecS, directedS, + using Traits = adjacency_list_traits; + using Graph = adjacency_list > >; + property>>; using out_edge_iterator = graph_traits::out_edge_iterator; using edge_descriptor = graph_traits::edge_descriptor; @@ -73,7 +73,7 @@ int main() Graph g; - using tCapMap = property_map < Graph, edge_capacity_t >::type; + using tCapMap = property_map::type; using tCapMapValue = tCapMap::value_type; auto capacity = get(edge_capacity, g); diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index b7350cd8..668bc9b6 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -41,7 +41,7 @@ using namespace boost; using Graph = adjacency_list >; + no_property, property>; struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 8fefca65..5df1dc7f 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -40,7 +40,7 @@ using namespace boost; */ using Graph = adjacency_list >; + no_property, property>; struct has_weight_greater_than { has_weight_greater_than(int w_, Graph& g_) : w(w_), g(g_) { } diff --git a/example/reverse_graph.cpp b/example/reverse_graph.cpp index 2c7aacf6..cffe24c3 100644 --- a/example/reverse_graph.cpp +++ b/example/reverse_graph.cpp @@ -20,7 +20,7 @@ int main() { using namespace boost; - using Graph = adjacency_list < vecS, vecS, bidirectionalS >; + using Graph = adjacency_list; Graph G(5); add_edge(0, 2, G); diff --git a/example/roget_components.cpp b/example/roget_components.cpp index 1a576cf0..1e7495ce 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) discover_time_map(get(z_property(), g)). color_map(get(w_property(), g))); - std::vector< std::vector > strong_comp(num_comp); + std::vector> strong_comp(num_comp); // First add representative vertices to each component's list graph_traits::vertex_iterator vi, vi_end; diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index 4099004b..0355ff3b 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -26,7 +26,7 @@ using namespace boost; template > + typename Divide = divides> struct scaled_closeness_measure { using distance_type = Distance; diff --git a/example/scc.cpp b/example/scc.cpp index 97e45053..87f6fbd8 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -19,15 +19,15 @@ main() GraphvizDigraph g; read_graphviz("figs/scc.dot", g); - using vertex_t = graph_traits < GraphvizDigraph >::vertex_descriptor; - std::map < vertex_t, int >component; + using vertex_t = graph_traits::vertex_descriptor; + std::map component; strong_components(g, make_assoc_property_map(component)); auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; - graph_traits < GraphvizDigraph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index f42b8ec3..a87c936e 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -85,7 +85,7 @@ int main(int , char* []) int, property< vertex_priority_t, - double > > > >; + double>>>>; using Vertex = graph_traits::vertex_descriptor; using size_type = graph_traits::vertices_size_type; diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index 13388d89..759bd3c8 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -26,7 +26,7 @@ int main() using namespace std; using undirected_graph = boost::adjacency_list >; + boost::no_property, boost::property>; using weight_map_type = boost::property_map::type; using weight_type = boost::property_traits::value_type; diff --git a/example/straight_line_drawing.cpp b/example/straight_line_drawing.cpp index 9c499055..87e2a11f 100644 --- a/example/straight_line_drawing.cpp +++ b/example/straight_line_drawing.cpp @@ -31,17 +31,12 @@ struct coord_t int main(int argc, char** argv) { - using graph = adjacency_list - < vecS, - vecS, - undirectedS, - property - >; - - + using graph = adjacency_list>; //Define the storage type for the planar embedding - using embedding_storage_t = std::vector< std::vector< graph_traits::edge_descriptor > >; + using embedding_storage_t = std::vector::edge_descriptor>>; using embedding_t = boost::iterator_property_map < embedding_storage_t::iterator, property_map::type @@ -92,7 +87,7 @@ int main(int argc, char** argv) //Set up a property map to hold the mapping from vertices to coord_t's - using straight_line_drawing_storage_t = std::vector< coord_t >; + using straight_line_drawing_storage_t = std::vector; using straight_line_drawing_t = boost::iterator_property_map < straight_line_drawing_storage_t::iterator, property_map::type diff --git a/example/strong-components.cpp b/example/strong-components.cpp index c9e50baa..ad813db7 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -15,7 +15,7 @@ int main() { using namespace boost; - using Graph = adjacency_list < vecS, vecS, directedS >; + using Graph = adjacency_list; const int N = 6; Graph G(N); add_edge(0, 1, G); diff --git a/example/strong_components.cpp b/example/strong_components.cpp index a6c61b86..c0f623d7 100644 --- a/example/strong_components.cpp +++ b/example/strong_components.cpp @@ -54,7 +54,7 @@ int main(int, char*[]) print_graph(G, name); std::cout << std::endl; - using Vertex = graph_traits >::vertex_descriptor; + using Vertex = graph_traits>::vertex_descriptor; std::vector component(num_vertices(G)), discover_time(num_vertices(G)); std::vector color(num_vertices(G)); diff --git a/example/subgraph.cpp b/example/subgraph.cpp index aeb89d78..d720c569 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -41,8 +41,8 @@ int main(int,char*[]) { using namespace boost; - using Graph = subgraph< adjacency_list, property > >; + using Graph = subgraph, property>>; const int N = 6; Graph G0(N); diff --git a/example/subgraph_properties.cpp b/example/subgraph_properties.cpp index b9e70e18..0e178203 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -39,11 +39,11 @@ int main(int,char*[]) { using namespace boost; //using Traits = adjacency_list_traits;// Does nothing? - using VertexProperty = property< vertex_color_t, int, - property< vertex_name_t, std::string > >; + using VertexProperty = property>; - using Graph = subgraph< adjacency_list< vecS, vecS, directedS, - VertexProperty, property > >; + using Graph = subgraph>>; const int N = 6; Graph G0(N); diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 98d61631..8e9690c1 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -16,28 +16,28 @@ using namespace boost; namespace std { - template < typename T > - std::istream & operator >> (std::istream & in, std::pair < T, T > &p) + template + std::istream & operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return in; } } -using file_dep_graph = adjacency_list < listS, // Store out-edges of each vertex in a std::list +using file_dep_graph = adjacency_list; -using vertex_t = graph_traits < file_dep_graph >::vertex_descriptor; -using edge_t = graph_traits < file_dep_graph >::edge_descriptor; +using vertex_t = graph_traits::vertex_descriptor; +using edge_t = graph_traits::edge_descriptor; void topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, int *mark) { mark[u] = 1; // 1 means visited, 0 means not yet visited - graph_traits < file_dep_graph >::adjacency_iterator vi, vi_end; + graph_traits::adjacency_iterator vi, vi_end; for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, mark); @@ -48,8 +48,8 @@ topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, void topo_sort(const file_dep_graph & g, vertex_t * topo_order) { - std::vector < int >mark(num_vertices(g), 0); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + std::vectormark(num_vertices(g), 0); + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, &mark[0]); @@ -60,10 +60,10 @@ int main() { std::ifstream file_in("makefile-dependencies.dat"); - using size_type = graph_traits < file_dep_graph >::vertices_size_type; + using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices - std::istream_iterator < std::pair < size_type, size_type > > + std::istream_iterator> input_begin(file_in), input_end; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor @@ -77,13 +77,13 @@ main() file_dep_graph g(input_begin, input_end, n_vertices); #endif - std::vector < std::string > name(num_vertices(g)); + std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; - std::vector < vertex_t > order(num_vertices(g)); + std::vector order(num_vertices(g)); topo_sort(g, &order[0] + num_vertices(g)); for (size_type i = 0; i < num_vertices(g); ++i) std::cout << name[order[i]] << std::endl; diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 6ab226d9..a414c992 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -16,9 +16,9 @@ using namespace boost; namespace std { - template < typename T > + template std::istream & - operator >> (std::istream & in, std::pair < T, T > &p) + operator >> (std::istream & in, std::pair &p) { in >> p.first >> p.second; return @@ -35,13 +35,13 @@ using file_dep_graph = adjacency_list < using vertex_t = graph_traits ::vertex_descriptor; using edge_t = graph_traits ::edge_descriptor; -template < typename Visitor > void +template void dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, Visitor vis) { color[u] = gray_color; vis.discover_vertex(u, g); - graph_traits < file_dep_graph >::out_edge_iterator ei, ei_end; + graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); @@ -55,11 +55,11 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, vis.finish_vertex(u, g); } -template < typename Visitor > void +template void generic_dfs_v1(const file_dep_graph & g, Visitor vis) { - std::vector < default_color_type > color(num_vertices(g), white_color); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + std::vector color(num_vertices(g), white_color); + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); @@ -68,27 +68,27 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis) struct dfs_visitor_default { - template < typename V, typename G > void + template void discover_vertex(V, const G &) { } - template < typename E, typename G > void + template void tree_edge(E, const G &) { } - template < typename E, typename G > void + template void back_edge(E, const G &) { } - template < typename E, typename G > void + template void forward_or_cross_edge(E, const G &) { } - template < typename V, typename G > void + template void finish_vertex(V, const G &) { } @@ -122,8 +122,8 @@ main() using size_type = graph_traits::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices - std::istream_iterator < std::pair < size_type, - size_type > >input_begin(file_in), input_end; + std::istream_iterator> input_begin(file_in), input_end; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor @@ -137,13 +137,13 @@ main() file_dep_graph g(input_begin, input_end, n_vertices); #endif - std::vector < std::string > name(num_vertices(g)); + std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; + graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; - std::vector < vertex_t > order(num_vertices(g)); + std::vector order(num_vertices(g)); topo_sort(g, &order[0] + num_vertices(g)); for (size_type i = 0; i < num_vertices(g); ++i) std::cout << name[order[i]] << std::endl; diff --git a/example/topo-sort-with-leda.cpp b/example/topo-sort-with-leda.cpp index 7cc4cd59..11edac49 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -17,10 +17,10 @@ int main() { using namespace boost; - using graph_t = GRAPH < std::string, char >; + using graph_t = GRAPH; graph_t leda_g; - using vertex_t = graph_traits < graph_t >::vertex_descriptor; - std::vector < vertex_t > vert(7); + using vertex_t = graph_traits::vertex_descriptor; + std::vector vert(7); vert[0] = add_vertex(std::string("pick up kids from school"), leda_g); vert[1] = add_vertex(std::string("buy groceries (and snacks)"), leda_g); vert[2] = add_vertex(std::string("get cash at ATM"), leda_g); @@ -38,8 +38,8 @@ main() add_edge(vert[4], vert[6], leda_g); add_edge(vert[5], vert[6], leda_g); - std::vector < vertex_t > topo_order; - node_array < default_color_type > color_array(leda_g); + std::vector topo_order; + node_array color_array(leda_g); topological_sort(leda_g, std::back_inserter(topo_order), color_map(make_leda_node_property_map(color_array))); diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index 30d7941d..9781b985 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -37,8 +37,8 @@ main() gb_new_arc(sgb_g->vertices + 4, sgb_g->vertices + 6, 0); gb_new_arc(sgb_g->vertices + 5, sgb_g->vertices + 6, 0); - using vertex_t = graph_traits < Graph * >::vertex_descriptor; - std::vector < vertex_t > topo_order; + using vertex_t = graph_traits::vertex_descriptor; + std::vector topo_order; topological_sort(sgb_g, std::back_inserter(topo_order), vertex_index_map(get(vertex_index, sgb_g))); int n = 1; diff --git a/example/topo-sort1.cpp b/example/topo-sort1.cpp index cb638532..79903503 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -26,7 +26,7 @@ main() "eat dinner" }; - std::vector < std::list < int > > g = { + std::vector> g = { {3}, {3, 4}, {1}, @@ -35,7 +35,7 @@ main() {6}, {}}; - std::deque < int >topo_order; + std::deque topo_order; topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); diff --git a/example/topo-sort2.cpp b/example/topo-sort2.cpp index c3d22ff2..2d004fea 100644 --- a/example/topo-sort2.cpp +++ b/example/topo-sort2.cpp @@ -26,7 +26,7 @@ main() }; const int n_tasks = sizeof(tasks) / sizeof(char *); - adjacency_list < listS, vecS, directedS > g(n_tasks); + adjacency_list g(n_tasks); add_edge(0, 3, g); add_edge(1, 3, g); @@ -36,7 +36,7 @@ main() add_edge(4, 6, g); add_edge(5, 6, g); - std::deque < int >topo_order; + std::deque topo_order; topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index e57e5517..1a5c048d 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -41,7 +41,7 @@ main(int , char* []) internal decorator, so we "property" the color to the graph. */ using Graph = adjacency_list >; + property>; using Vertex = boost::graph_traits::vertex_descriptor; @@ -56,7 +56,7 @@ main(int , char* []) auto id = get(vertex_index, G); - using container = std::vector< Vertex >; + using container = std::vector; container c; topological_sort(G, std::back_inserter(c)); diff --git a/example/transitive_closure.cpp b/example/transitive_closure.cpp index 8646ec84..2f30160e 100644 --- a/example/transitive_closure.cpp +++ b/example/transitive_closure.cpp @@ -18,12 +18,12 @@ int main(int, char *[]) { using namespace boost; - using Name = property < vertex_name_t, char >; - using Index = property < vertex_index_t, std::size_t, Name >; - using graph_t = adjacency_list < listS, listS, directedS, Index >; - using vertex_t = graph_traits < graph_t >::vertex_descriptor; + using Name = property; + using Index = property; + using graph_t = adjacency_list; + using vertex_t = graph_traits::vertex_descriptor; graph_t G; - std::vector < vertex_t > verts(4); + std::vector verts(4); for (int i = 0; i < 4; ++i) verts[i] = add_vertex(Index(i, Name('a' + i)), G); add_edge(verts[1], verts[2], G); diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 28a8eeeb..99725425 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -15,18 +15,18 @@ int main() { using namespace boost; - using graph_t = adjacency_list < vecS, vecS, bidirectionalS, - property < vertex_name_t, char > >; + using graph_t = adjacency_list>; enum { a, b, c, d, e, f, g, N }; graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits < graph_t >::vertex_iterator v, v_end; + graph_traits::vertex_iterator v, v_end; for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - using E = std::pair < int, int >; + using E = std::pair; E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; @@ -41,7 +41,7 @@ main() print_graph(G_T, name_map); - graph_traits < graph_t >::edge_iterator ei, ei_end; + graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) assert(edge(target(*ei, G), source(*ei, G), G_T).second == true); return 0; diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index baaa4a6f..a089c706 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -45,7 +45,7 @@ boost::graph_traits::edge_iterator; int main(int argc, char **argv) { Graph iG, vG; - vector< edge_descriptor > iG_o = { + vector iG_o = { boost::add_edge(0, 1, iG).first, boost::add_edge(0, 2, iG).first, boost::add_edge(0, 3, iG).first, @@ -53,7 +53,7 @@ int main(int argc, char **argv) boost::add_edge(1, 2, iG).first, boost::add_edge(3, 4, iG).first}; - vector< edge_descriptor > vG_o= { + vector vG_o= { boost::add_edge(1, 2, vG).first, boost::add_edge(2, 0, vG).first, boost::add_edge(2, 3, vG).first, @@ -63,9 +63,9 @@ int main(int argc, char **argv) vector inL(iG_o.size(), false); - std::vector< std::vector > coll; + std::vector> coll; boost::tree_collector< - std::vector< std::vector >, + std::vector>, std::vector > tree_collector(coll); boost::two_graphs_common_spanning_trees diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index f82f71b7..0489d7fa 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -10,13 +10,13 @@ #include using namespace boost; -template < typename UndirectedGraph > void +template void undirected_graph_demo1() { const int V = 3; UndirectedGraph undigraph(V); - typename graph_traits < UndirectedGraph >::out_edge_iterator out, out_end; - typename graph_traits < UndirectedGraph >::in_edge_iterator in, in_end; + typename graph_traits::out_edge_iterator out, out_end; + typename graph_traits::in_edge_iterator in, in_end; auto zero = vertex(0, undigraph); auto one = vertex(1, undigraph); @@ -34,14 +34,14 @@ undirected_graph_demo1() std::cout << std::endl; } -template < typename DirectedGraph > void +template void directed_graph_demo() { const int V = 2; DirectedGraph digraph(V); using Weight = typename DirectedGraph::edge_property_type; auto weight = get(edge_weight, digraph); - typename graph_traits < DirectedGraph >::edge_descriptor e1, e2; + typename graph_traits::edge_descriptor e1, e2; bool found; auto u = vertex(0, digraph); @@ -62,15 +62,15 @@ directed_graph_demo() std::cout << "weight[(v,u)] = " << get(weight, e2) << std::endl; } -template < typename UndirectedGraph > void +template void undirected_graph_demo2() { const int V = 2; UndirectedGraph undigraph(V); using Weight = typename UndirectedGraph::edge_property_type; - typename property_map < UndirectedGraph, edge_weight_t >::type + typename property_map::type weight = get(edge_weight, undigraph); - typename graph_traits < UndirectedGraph >::edge_descriptor e1, e2; + typename graph_traits::edge_descriptor e1, e2; bool found; auto u = vertex(0, undigraph); @@ -105,8 +105,8 @@ main() no_property, Weight >; using DirectedGraph = adjacency_list < vecS, vecS, directedS, no_property, Weight >; - undirected_graph_demo1 < UndirectedGraph > (); - directed_graph_demo < DirectedGraph > (); - undirected_graph_demo2 < UndirectedGraph > (); + undirected_graph_demo1 (); + directed_graph_demo (); + undirected_graph_demo2 (); return 0; } diff --git a/example/undirected_dfs.cpp b/example/undirected_dfs.cpp index 1dec46d4..fffac592 100644 --- a/example/undirected_dfs.cpp +++ b/example/undirected_dfs.cpp @@ -47,7 +47,7 @@ int main(int, char*[]) using namespace boost; using graph_t = adjacency_list< vecS, vecS, undirectedS, no_property, - property >; + property>; using vertex_t = graph_traits::vertex_descriptor; const std::size_t N = sizeof(name)/sizeof(std::string); diff --git a/example/vector_as_graph.cpp b/example/vector_as_graph.cpp index e1b364f1..b62dd7e7 100644 --- a/example/vector_as_graph.cpp +++ b/example/vector_as_graph.cpp @@ -22,7 +22,7 @@ main() enum { r, s, t, u, v, w, x, y }; char name[] = "rstuvwxy"; - using Graph = std::vector < std::list < int > >; + using Graph = std::vector>; Graph g = { {v}, //r {r, r, w}, //s diff --git a/example/vertex-name-property.cpp b/example/vertex-name-property.cpp index e2adf00b..9024a0bb 100644 --- a/example/vertex-name-property.cpp +++ b/example/vertex-name-property.cpp @@ -13,14 +13,14 @@ using namespace boost; -template < typename Graph, typename VertexNamePropertyMap > void +template void read_graph_file(std::istream & graph_in, std::istream & name_in, Graph & g, VertexNamePropertyMap name_map) { - using size_type = typename graph_traits < Graph >::vertices_size_type; + using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits < Graph >::vertex_descriptor u; - typename property_traits < VertexNamePropertyMap >::value_type name; + typename graph_traits::vertex_descriptor u; + typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph @@ -43,7 +43,7 @@ main() using graph_type = adjacency_list < listS, // Store out-edges of each vertex in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed - property < vertex_name_t, std::string > // Add a vertex property + property // Add a vertex property >; graph_type g; // use default constructor to create empty graph @@ -66,10 +66,10 @@ main() read_graph_file(file_in, name_in, g, name_map); // Create storage for last modified times - std::vector < time_t > last_mod_vec(num_vertices(g)); + std::vector last_mod_vec(num_vertices(g)); // Create nickname for the property map type - using iter_map_t = iterator_property_map < std::vector < time_t >::iterator, - property_map < graph_type, vertex_index_t >::type, time_t, time_t& >; + using iter_map_t = iterator_property_map < std::vector::iterator, + property_map::type, time_t, time_t&>; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); diff --git a/example/vf2_sub_graph_iso_multi_example.cpp b/example/vf2_sub_graph_iso_multi_example.cpp index 98d26cc3..1a71c600 100644 --- a/example/vf2_sub_graph_iso_multi_example.cpp +++ b/example/vf2_sub_graph_iso_multi_example.cpp @@ -12,7 +12,7 @@ using namespace boost; int main() { using edge_property = property; - using vertex_property = property >; + using vertex_property = property>; // Using a vecS graphs => the index maps are implicit. using graph_type = adjacency_list; diff --git a/example/visitor.cpp b/example/visitor.cpp index 335b21a0..4a87a4d8 100644 --- a/example/visitor.cpp +++ b/example/visitor.cpp @@ -48,7 +48,7 @@ using namespace boost; using namespace std; template -struct edge_printer : public base_visitor > { +struct edge_printer : public base_visitor> { using event_filter = Tag; edge_printer(std::string edge_t) : m_edge_type(edge_t) { } template diff --git a/example/write_graphviz.cpp b/example/write_graphviz.cpp index 3aeded0a..313b9275 100644 --- a/example/write_graphviz.cpp +++ b/example/write_graphviz.cpp @@ -48,9 +48,9 @@ int main(int,char*[]) using namespace boost; - using Graph = adjacency_list< vecS, vecS, directedS, - property< vertex_color_t, default_color_type >, - property< edge_weight_t, int > + using Graph = adjacency_list, + property >; Graph g(used_by, used_by + nedges, weights, N); From 0fc224c146359c0b5a3ebfa6a2e138635154dc71 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 6 May 2016 22:22:26 +0200 Subject: [PATCH 10/28] examples: Remove unused typedefs. --- example/edge_connectivity.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/example/edge_connectivity.cpp b/example/edge_connectivity.cpp index ccc7a654..5dc581bd 100644 --- a/example/edge_connectivity.cpp +++ b/example/edge_connectivity.cpp @@ -41,7 +41,6 @@ main() add_edge(6, 7, g); using edge_descriptor = graph_traits::edge_descriptor; - using degree_size_type = graph_traits::degree_size_type; std::vector disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); From 456ed23be1ba76d283f5cda478e0902ec0282b8e Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 8 Oct 2016 22:23:08 +0200 Subject: [PATCH 11/28] Examples; Remove unused variables. --- example/accum-compile-times.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 03ebc590..df73f2cf 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -70,8 +70,6 @@ main() auto name_map = get(vertex_name, g); auto compile_cost_map = get(vertex_compile_cost, g); - auto distance_map = get(vertex_distance, g); - auto color_map = get(vertex_color, g); std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); From 36a9ff52fd491af8b236f49147e66622c1bd0e1a Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 8 Oct 2016 22:23:31 +0200 Subject: [PATCH 12/28] Examples: Avoid a signed/unsigned comparison warning. --- example/fibonacci_heap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index 7ee6de7d..fab14e26 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -33,7 +33,7 @@ main() ICmp cmp(&w[0], std::less()); fibonacci_heap Q(N, cmp); - for (int c = 0; c < w.size(); ++c) + for (std::size_t c = 0; c < w.size(); ++c) w[c] = c; std::random_shuffle(w.begin(), w.end()); From 4544c1f8aea92376300cdd33e2840f784a708267 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 May 2016 15:52:53 +0200 Subject: [PATCH 13/28] examples: Remove "using std". Because it makes the code less clear. --- example/adjacency_list.cpp | 18 +++++------ example/astar-cities.cpp | 31 ++++++++++--------- example/bron_kerbosch_clique_number.cpp | 5 ++-- example/bron_kerbosch_print_cliques.cpp | 11 ++++--- example/bucket_sorter.cpp | 31 ++++++++++--------- example/city_visitor.cpp | 27 ++++++++--------- example/closeness_centrality.cpp | 11 ++++--- example/clustering_coefficient.cpp | 13 ++++---- example/components_on_edgelist.cpp | 21 +++++++------ example/connected_components.cpp | 8 ++--- example/cuthill_mckee_ordering.cpp | 25 ++++++++-------- example/cycle_ratio_example.cpp | 14 ++++----- example/dave.cpp | 15 ++++------ example/degree_centrality.cpp | 11 ++++--- example/dfs.cpp | 21 +++++++------ example/dfs_parenthesis.cpp | 1 - example/dijkstra-example-listS.cpp | 3 +- example/dijkstra-example.cpp | 3 +- example/dijkstra-no-color-map-example.cpp | 3 +- example/eccentricity.cpp | 15 +++++----- example/edge-connectivity.cpp | 3 +- example/edge_basics.cpp | 9 +++--- example/edge_coloring.cpp | 5 ++-- example/edge_property.cpp | 12 ++++---- example/exterior_property_map.cpp | 9 +++--- example/file_dependencies.cpp | 37 +++++++++++------------ example/graph-thingie.cpp | 23 +++++++------- example/graph.cpp | 38 +++++++++++------------ example/graph_property.cpp | 3 +- example/in_edges.cpp | 7 ++--- example/inclusive_mean_geodesic.cpp | 25 ++++++++-------- example/influence_prestige.cpp | 11 ++++--- example/interior_pmap_bundled.cpp | 11 ++++--- example/interior_property_map.cpp | 9 +++--- example/king_ordering.cpp | 25 ++++++++-------- example/labeled_graph.cpp | 5 ++-- example/mean_geodesic.cpp | 13 ++++---- example/minimum_degree_ordering.cpp | 25 ++++++++-------- example/read_graphviz.cpp | 1 - example/scaled_closeness_centrality.cpp | 11 ++++--- example/sloan_ordering.cpp | 45 +++++++++++++--------------- example/stoer_wagner.cpp | 18 +++++------ example/tiernan_girth_circumference.cpp | 7 ++--- example/tiernan_print_cycles.cpp | 7 ++--- example/two_graphs_common_spanning_trees.cpp | 9 ++---- example/vertex_basics.cpp | 31 ++++++++++--------- example/visitor.cpp | 5 ++-- 47 files changed, 314 insertions(+), 377 deletions(-) diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index 46dac9e3..b1ee5348 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -51,7 +51,6 @@ struct VertexProperties { int main(int , char* []) { using namespace boost; - using namespace std; using Graph = adjacency_list; @@ -77,26 +76,25 @@ int main(int , char* []) graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; for (boost::tie(i,end) = vertices(g); i != end; ++i) { - cout << id[*i] << " "; + std::cout << id[*i] << " "; for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; - cout << endl; + std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; } print_edges(g, id); - cout << endl << "removing edge (1,3): " << endl; + std::cout << std::endl << "removing edge (1,3): " << std::endl; remove_edge(vertex(1, g), vertex(3, g), g); ei = out_edges(vertex(1, g), g).first; - cout << "removing edge (" << id[source(*ei, g)] - << "," << id[target(*ei, g)] << ")" << endl; + std::cout << "removing edge (" << id[source(*ei, g)] + << "," << id[target(*ei, g)] << ")" << std::endl; remove_edge(ei, g); for(boost::tie(i,end) = vertices(g); i != end; ++i) { - cout << id[*i] << " "; + std::cout << id[*i] << " "; for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; - cout << endl; + std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + std::cout << std::endl; } print_edges(g, id); diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 0540fee6..30e658bb 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -24,7 +24,6 @@ #include // for sqrt using namespace boost; -using namespace std; // auxiliary types @@ -43,7 +42,7 @@ class city_writer { : name(n), loc(l), minx(_minx), maxx(_maxx), miny(_miny), maxy(_maxy), ptx(_ptx), pty(_pty) {} template - void operator()(ostream& out, const Vertex& v) const { + void operator()(std::ostream& out, const Vertex& v) const { float px = 1 - (loc[v].x - minx) / (maxx - minx); float py = (loc[v].y - miny) / (maxy - miny); out << "[label=\"" << name[v] << "\", pos=\"" @@ -62,8 +61,8 @@ template class time_writer { public: time_writer(WeightMap w) : wm(w) {} - template - void operator()(ostream &out, const Edge& e) const { + template + void operator()(std::ostream &out, const Edge& e) const { out << "[label=\"" << wm[e] << "\", fontsize=\"11\"]"; } private: @@ -175,10 +174,10 @@ int main(int argc, char **argv) auto goal = random_vertex(g, gen); - cout << "Start vertex: " << name[start] << endl; - cout << "Goal vertex: " << name[goal] << endl; + std::cout << "Start vertex: " << name[start] << std::endl; + std::cout << "Goal vertex: " << name[goal] << std::endl; - ofstream dotfile; + std::ofstream dotfile; dotfile.open("test-astar-cities.dot"); write_graphviz(dotfile, g, city_writer @@ -187,8 +186,8 @@ int main(int argc, char **argv) time_writer(weightmap)); - vector p(num_vertices(g)); - vector d(num_vertices(g)); + std::vector p(num_vertices(g)); + std::vector d(num_vertices(g)); try { // call astar named parameter interface astar_search_tree @@ -201,24 +200,24 @@ int main(int argc, char **argv) } catch(found_goal fg) { // found a path to the goal - list shortest_path; + std::list shortest_path; for(auto v = goal;; v = p[v]) { shortest_path.emplace_front(v); if(p[v] == v) break; } - cout << "Shortest path from " << name[start] << " to " + std::cout << "Shortest path from " << name[start] << " to " << name[goal] << ": "; auto spi = shortest_path.begin(); - cout << name[start]; + std::cout << name[start]; for(++spi; spi != shortest_path.end(); ++spi) - cout << " -> " << name[*spi]; - cout << endl << "Total travel time: " << d[goal] << endl; + std::cout << " -> " << name[*spi]; + std::cout << std::endl << "Total travel time: " << d[goal] << std::endl; return 0; } - cout << "Didn't find a path from " << name[start] << "to" - << name[goal] << "!" << endl; + std::cout << "Didn't find a path from " << name[start] << "to" + << name[goal] << "!" << std::endl; return 0; } diff --git a/example/bron_kerbosch_clique_number.cpp b/example/bron_kerbosch_clique_number.cpp index 232d84e8..1c809fa9 100644 --- a/example/bron_kerbosch_clique_number.cpp +++ b/example/bron_kerbosch_clique_number.cpp @@ -12,7 +12,6 @@ #include "helper.hpp" -using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. @@ -25,11 +24,11 @@ main(int argc, char *argv[]) { // Create the graph and read it from standard input. Graph g; - read_graph(g, cin); + read_graph(g, std::cin); // Use the Bron-Kerbosch algorithm to find all cliques, and auto c = bron_kerbosch_clique_number(g); - cout << "clique number: " << c << endl; + std::cout << "clique number: " << c << std::endl; return 0; } diff --git a/example/bron_kerbosch_print_cliques.cpp b/example/bron_kerbosch_print_cliques.cpp index 100d9fb8..72744727 100644 --- a/example/bron_kerbosch_print_cliques.cpp +++ b/example/bron_kerbosch_print_cliques.cpp @@ -12,7 +12,6 @@ #include "helper.hpp" -using namespace std; using namespace boost; // The clique_printer is a visitor that will print the vertices that comprise @@ -32,7 +31,7 @@ struct clique_printer for(i = c.begin(); i != end; ++i) { os << g[*i].name << " "; } - os << endl; + os << std::endl; } OutputStream& os; }; @@ -40,7 +39,7 @@ struct clique_printer // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -50,7 +49,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; int main(int argc, char *argv[]) @@ -60,10 +59,10 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Instantiate the visitor for printing cliques - clique_printer vis(cout); + clique_printer vis(std::cout); // Use the Bron-Kerbosch algorithm to find all cliques, printing them // as they are found. diff --git a/example/bucket_sorter.cpp b/example/bucket_sorter.cpp index 56b766da..0b7d4f49 100644 --- a/example/bucket_sorter.cpp +++ b/example/bucket_sorter.cpp @@ -25,21 +25,20 @@ struct trivial_id { int main() { - using namespace std; using boost::bucket_sorter; const std::size_t N = 10; - vector bucket(N); + std::vector bucket(N); for (std::size_t i=0; i; using BS = bucket_sorter::iterator, ID>; + std::vector::iterator, ID>; BS my_bucket_sorter(N, N, bucket.begin()); for (std::size_t ii=0; ii { - city_arrival(string* n) : names(n) { } + city_arrival(std::string* n) : names(n) { } using event_filter = on_discover_vertex; template inline void operator()(Vertex u, Graph&) { - cout << endl << "arriving at " << names[u] << endl + std::cout << std::endl << "arriving at " << names[u] << std::endl << " neighboring cities are: "; } - string* names; + std::string* names; }; struct neighbor_cities : public base_visitor { - neighbor_cities(string* n) : names(n) { } + neighbor_cities(std::string* n) : names(n) { } using event_filter = on_examine_edge; template inline void operator()(Edge e, Graph& g) { - cout << names[ target(e, g) ] << ", "; + std::cout << names[ target(e, g) ] << ", "; } - string* names; + std::string* names; }; struct finish_city : public base_visitor { - finish_city(string* n) : names(n) { } + finish_city(std::string* n) : names(n) { } using event_filter = on_finish_vertex; template inline void operator()(Vertex u, Graph&) { - cout << endl << "finished with " << names[u] << endl; + std::cout << std::endl << "finished with " << names[u] << std::endl; } - string* names; + std::string* names; }; int main(int, char*[]) @@ -95,7 +94,7 @@ int main(int, char*[]) enum { SanJose, SanFran, LA, SanDiego, Fresno, LasVegas, Reno, Sacramento, SaltLake, Phoenix, N }; - string names[] = { "San Jose", "San Francisco", "Los Angeles", "San Diego", + std::string names[] = { "San Jose", "San Francisco", "Los Angeles", "San Diego", "Fresno", "Las Vegas", "Reno", "Sacramento", "Salt Lake City", "Phoenix" }; @@ -118,18 +117,18 @@ int main(int, char*[]) Graph G(edge_array, edge_array + sizeof(edge_array)/sizeof(E), N); #endif - cout << "*** Depth First ***" << endl; + std::cout << "*** Depth First ***" << std::endl; depth_first_search (G, visitor(make_dfs_visitor(boost::make_list(city_arrival(names), neighbor_cities(names), finish_city(names))))); - cout << endl; + std::cout << std::endl; /* Get the source vertex */ auto s = vertex(SanJose,G); - cout << "*** Breadth First ***" << endl; + std::cout << "*** Breadth First ***" << std::endl; breadth_first_search (G, s, visitor(make_bfs_visitor(boost::make_list(city_arrival(names), neighbor_cities(names), diff --git a/example/closeness_centrality.cpp b/example/closeness_centrality.cpp index 290eaf07..aec94ed7 100644 --- a/example/closeness_centrality.cpp +++ b/example/closeness_centrality.cpp @@ -15,13 +15,12 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -31,7 +30,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. @@ -58,7 +57,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the distances between all pairs of vertices using // the Floyd-Warshall algorithm. Note that the weight map is @@ -76,8 +75,8 @@ main(int argc, char *argv[]) // Print the closeness centrality of each vertex. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) - << g[*i].name << get(cm, *i) << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[*i].name << get(cm, *i) << std::endl; } return 0; diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index bde6be69..39e89584 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -14,13 +14,12 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -30,7 +29,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // The clustering property, container, and map define the containment // and abstract accessor for the clustering coefficients of vertices. @@ -47,7 +46,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the clustering coefficients of each vertex in the graph // and the mean clustering coefficient which is returned from the @@ -59,10 +58,10 @@ main(int argc, char *argv[]) // Print the clustering coefficient of each vertex. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) - << g[*i].name << get(cm, *i) << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[*i].name << get(cm, *i) << std::endl; } - cout << "mean clustering coefficient: " << cc << endl; + std::cout << "mean clustering coefficient: " << cc << std::endl; return 0; } diff --git a/example/components_on_edgelist.cpp b/example/components_on_edgelist.cpp index 5817c465..852c3533 100644 --- a/example/components_on_edgelist.cpp +++ b/example/components_on_edgelist.cpp @@ -49,14 +49,13 @@ */ -using namespace std; using boost::tie; int main(int , char* []) { using namespace boost; using Index = int; // ID of a Vertex - using Edge = pair; + using Edge = std::pair; const int N = 6; const int E = 4; Edge edgelist[] = { Edge(0, 1), Edge(1, 4), Edge(4, 0), Edge(2, 5) }; @@ -64,9 +63,9 @@ int main(int , char* []) edge_list g(edgelist, edgelist + E); - cout << "An undirected graph (edge list):" << endl; + std::cout << "An undirected graph (edge list):" << std::endl; print_edges(g, identity_property_map()); - cout << endl; + std::cout << std::endl; disjoint_sets_with_storage<> ds(N); incremental_components(g, ds); @@ -74,20 +73,20 @@ int main(int , char* []) component_index components(&ds.parents()[0], &ds.parents()[0] + ds.parents().size()); - cout << "Total number of components: " << components.size() << endl; + std::cout << "Total number of components: " << components.size() << std::endl; for (int k = 0; k != N; ++k) - cout << "Vertex " << k << " is in the component who's representative is " - << ds.find_set(k) << endl; - cout << endl; + std::cout << "Vertex " << k << " is in the component who's representative is " + << ds.find_set(k) << std::endl; + std::cout << std::endl; for (std::size_t i = 0; i < components.size(); ++i) { - cout << "component " << i << " contains: "; + std::cout << "component " << i << " contains: "; component_index::component_iterator j = components[i].first, jend = components[i].second; for ( ; j != jend; ++j) - cout << *j << " "; - cout << endl; + std::cout << *j << " "; + std::cout << std::endl; } return 0; diff --git a/example/connected_components.cpp b/example/connected_components.cpp index 3640f42c..091b3443 100644 --- a/example/connected_components.cpp +++ b/example/connected_components.cpp @@ -34,8 +34,6 @@ */ -using namespace std; - int main(int , char* []) { using namespace boost; @@ -52,10 +50,10 @@ int main(int , char* []) auto num = connected_components(G, &component[0]); std::vector::size_type i; - cout << "Total number of components: " << num << endl; + std::cout << "Total number of components: " << num << std::endl; for (i = 0; i != component.size(); ++i) - cout << "Vertex " << i <<" is in component " << component[i] << endl; - cout << endl; + std::cout << "Vertex " << i <<" is in component " << component[i] << std::endl; + std::cout << std::endl; } return 0; } diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 43b98512..9daa51a8 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -32,7 +32,6 @@ int main(int , char* []) { using namespace boost; - using namespace std; using Graph = adjacency_list>>; @@ -76,11 +75,11 @@ int main(int , char* []) //reverse cuthill_mckee_ordering cuthill_mckee_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G)); - cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; - cout << " "; + std::cout << "Reverse Cuthill-McKee ordering starting at: " << s << std::endl; + std::cout << " "; for (const auto& vertex : inv_perm) - cout << index_map[vertex] << " "; - cout << endl; + std::cout << index_map[vertex] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; @@ -93,11 +92,11 @@ int main(int , char* []) //reverse cuthill_mckee_ordering cuthill_mckee_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G)); - cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; - cout << " "; + std::cout << "Reverse Cuthill-McKee ordering starting at: " << s << std::endl; + std::cout << " "; for (const auto& vertex : inv_perm) - cout << index_map[vertex] << " "; - cout << endl; + std::cout << index_map[vertex] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; @@ -111,11 +110,11 @@ int main(int , char* []) cuthill_mckee_ordering(G, inv_perm.rbegin(), get(vertex_color, G), make_degree_map(G)); - cout << "Reverse Cuthill-McKee ordering:" << endl; - cout << " "; + std::cout << "Reverse Cuthill-McKee ordering:" << std::endl; + std::cout << " "; for (const auto& vertex : inv_perm) - cout << index_map[vertex] << " "; - cout << endl; + std::cout << index_map[vertex] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 4887f386..cb13bce6 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -43,8 +43,6 @@ void gen_rand_graph(TG &g, size_t nV, size_t nE) int main(int argc, char* argv[]) { - using std::cout; - using std::endl; const double epsilon = 0.0000001; double min_cr, max_cr; ///Minimum and maximum cycle ratio using ccReal_t = std::vector::edge_descriptor>; @@ -56,19 +54,19 @@ int main(int argc, char* argv[]) auto ew2 = get(edge_weight2, tgr); gen_rand_graph(tgr, 1000, 30000); - cout << "Vertices number: " << num_vertices(tgr) << endl; - cout << "Edges number: " << num_edges(tgr) << endl; + std::cout << "Vertices number: " << num_vertices(tgr) << std::endl; + std::cout << "Edges number: " << num_edges(tgr) << std::endl; int i = 0; graph_traits::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { vim[*vi] = i++; ///Initialize vertex index property } max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); - cout << "Maximum cycle ratio is " << max_cr << endl; + std::cout << "Maximum cycle ratio is " << max_cr << std::endl; min_cr = minimum_cycle_ratio(tgr, vim, ew1, ew2, &cc); - cout << "Minimum cycle ratio is " << min_cr << endl; + std::cout << "Minimum cycle ratio is " << min_cr << std::endl; std::pair cr(.0,.0); - cout << "Critical cycle:\n"; + std::cout << "Critical cycle:\n"; for (const auto& edge : cc) { cr.first += ew1[edge]; @@ -76,7 +74,7 @@ int main(int argc, char* argv[]) std::cout << "(" << vim[source(edge, tgr)] << "," << vim[target(edge, tgr)] << ") "; } - cout << endl; + std::cout << std::endl; assert(std::abs(cr.first / cr.second - min_cr) < epsilon); return EXIT_SUCCESS; } diff --git a/example/dave.cpp b/example/dave.cpp index 884c9243..3d6eedc0 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -21,7 +21,6 @@ #include #include -using namespace std; using namespace boost; /* This example does a best-first-search (using dijkstra's) and @@ -144,13 +143,11 @@ void print(Graph& G, Name name) { typename boost::graph_traits::vertex_iterator ui, uiend; for (boost::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) { - cout << name[*ui] << " --> "; + std::cout << name[*ui] << " --> "; typename boost::graph_traits::adjacency_iterator vi, viend; for(boost::tie(vi, viend) = adjacent_vertices(*ui, G); vi != viend; ++vi) - cout << name[*vi] << " "; - cout << endl; + std::cout << name[*vi] << " "; } - } @@ -164,7 +161,7 @@ main(int , char* []) Graph G(N); auto vertex_id = get(vertex_index, G); - std::vector distance(N, (numeric_limits::max)()); + std::vector distance(N, (std::numeric_limits::max)()); using Vertex = boost::graph_traits::vertex_descriptor; std::vector parent(N); @@ -192,7 +189,7 @@ main(int , char* []) adjacency_list> G_copy(N); - cout << "Starting graph:" << endl; + std::cout << "Starting graph:" << std::endl; std::ostream_iterator cout_int(std::cout, " "); std::ostream_iterator cout_char(std::cout, " "); @@ -226,8 +223,8 @@ main(int , char* []) parent[0])). visitor(make_dijkstra_visitor(copy_graph(G_copy, on_examine_edge())))); - cout << endl; - cout << "Result:" << endl; + std::cout << std::endl; + std::cout << "Result:" << std::endl; boost::breadth_first_search (G, vertex(a, G), visitor(make_bfs_visitor( diff --git a/example/degree_centrality.cpp b/example/degree_centrality.cpp index d6079dce..6ba33b41 100644 --- a/example/degree_centrality.cpp +++ b/example/degree_centrality.cpp @@ -15,13 +15,12 @@ #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -31,7 +30,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a container type for degree centralities and its // corresponding property map. @@ -48,7 +47,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the degree centrality for graph. CentralityContainer cents(num_vertices(g)); @@ -58,8 +57,8 @@ main(int argc, char *argv[]) // Print the degree centrality of each vertex. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setiosflags(ios::left) << setw(12) - << g[*i].name << cm[*i] << endl; + std::cout << std::setiosflags(std::ios::left) << std::setw(12) + << g[*i].name << cm[*i] << std::endl; } return 0; diff --git a/example/dfs.cpp b/example/dfs.cpp index fbe03c87..d08faafb 100644 --- a/example/dfs.cpp +++ b/example/dfs.cpp @@ -48,7 +48,6 @@ */ using namespace boost; -using namespace std; template @@ -59,26 +58,26 @@ struct edge_categorizer : public dfs_visitor { template void tree_edge(Edge e, Graph& G) { - cout << "Tree edge: " << source(e, G) << - " --> " << target(e, G) << endl; + std::cout << "Tree edge: " << source(e, G) << + " --> " << target(e, G) << std::endl; Base::tree_edge(e, G); } template void back_edge(Edge e, Graph& G) { - cout << "Back edge: " << source(e, G) - << " --> " << target(e, G) << endl; + std::cout << "Back edge: " << source(e, G) + << " --> " << target(e, G) << std::endl; Base::back_edge(e, G); } template void forward_or_cross_edge(Edge e, Graph& G) { - cout << "Forward or cross edge: " << source(e, G) - << " --> " << target(e, G) << endl; + std::cout << "Forward or cross edge: " << source(e, G) + << " --> " << target(e, G) << std::endl; Base::forward_or_cross_edge(e, G); } template void finish_edge(Edge e, Graph& G) { - cout << "Finish edge: " << source(e, G) << - " --> " << target(e, G) << endl; + std::cout << "Finish edge: " << source(e, G) << + " --> " << target(e, G) << std::endl; Base::finish_edge(e, G); } }; @@ -113,12 +112,12 @@ main(int , char* []) std::vector f(num_vertices(G)); int t = 0; depth_first_search(G, visitor(categorize_edges( - make_pair(stamp_times(&d[0], t, on_discover_vertex()), + std::make_pair(stamp_times(&d[0], t, on_discover_vertex()), stamp_times(&f[0], t, on_finish_vertex()))))); std::vector::iterator i, j; for (i = d.begin(), j = f.begin(); i != d.end(); ++i, ++j) - cout << *i << " " << *j << endl; + std::cout << *i << " " << *j << std::endl; return 0; } diff --git a/example/dfs_parenthesis.cpp b/example/dfs_parenthesis.cpp index 151f087c..3e8a650b 100644 --- a/example/dfs_parenthesis.cpp +++ b/example/dfs_parenthesis.cpp @@ -25,7 +25,6 @@ #include "boost/graph/depth_first_search.hpp" using namespace boost; -using namespace std; struct open_paren : public base_visitor { using event_filter = on_discover_vertex; diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index fb363649..2713dc9c 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -59,8 +59,7 @@ main(int, char *[]) graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: - endl; + std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } std::cout << std::endl; diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 011c95f5..c7384e74 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -46,8 +46,7 @@ main(int, char *[]) graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: - endl; + std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } std::cout << std::endl; diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index 9c4cc20a..b13fc848 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -50,8 +50,7 @@ main(int, char *[]) graph_traits::vertex_iterator vi, vend; for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: - endl; + std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } std::cout << std::endl; diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index b9c4de5e..f15c97f2 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -15,13 +15,12 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -31,7 +30,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. @@ -58,7 +57,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the distances between all pairs of vertices using // the Floyd-Warshall algorithm. Note that the weight map is @@ -78,11 +77,11 @@ main(int argc, char *argv[]) // Print the closeness centrality of each vertex. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) - << g[*i].name << get(em, *i) << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[*i].name << get(em, *i) << std::endl; } - cout << "radius: " << r << endl; - cout << "diamter: " << d << endl; + std::cout << "radius: " << r << std::endl; + std::cout << "diamter: " << d << std::endl; return 0; } diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 16f80be3..db67fb07 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -160,8 +160,7 @@ main() std::cout << "The disconnecting set is {"; for (const auto& edge : disconnecting_set) - std:: - cout << "(" << attr_map[source(edge, g)]["label"] << "," << + std::cout << "(" << attr_map[source(edge, g)]["label"] << "," << attr_map[target(edge, g)]["label"] << ") "; std::cout << "}." << std::endl; return EXIT_SUCCESS; diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index 48729c2b..8825bd12 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -12,7 +12,6 @@ #include #include -using namespace std; using namespace boost; @@ -56,7 +55,7 @@ struct exercise_edge { auto targ = target(e, G); // print out the vertex id's just because - cout << "(" << src << "," << targ << ") "; + std::cout << "(" << src << "," << targ << ") "; //end } @@ -69,7 +68,7 @@ main() { using MyGraph = adjacency_list<>; - using Pair = pair; + using Pair = std::pair; Pair edge_array[8] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1) }; @@ -82,7 +81,7 @@ main() // Use the STL for_each algorithm to "exercise" all of the edges in // the graph - for_each(edges(G).first, edges(G).second, exercise_edge(G)); - cout << endl; + std::for_each(edges(G).first, edges(G).second, exercise_edge(G)); + std::cout << std::endl; return 0; } diff --git a/example/edge_coloring.cpp b/example/edge_coloring.cpp index 76e84c1b..b0385519 100644 --- a/example/edge_coloring.cpp +++ b/example/edge_coloring.cpp @@ -35,7 +35,6 @@ int main(int, char *[]) { using namespace boost; - using namespace std; using Graph = adjacency_list; using Pair = std::pair; @@ -61,9 +60,9 @@ int main(int, char *[]) size_t colors = edge_coloring(G, get(edge_bundle, G)); - cout << "Colored using " << colors << " colors" << endl; + std::cout << "Colored using " << colors << " colors" << std::endl; for (size_t i = 0; i < sizeof(edges)/sizeof(edges[0]); i++) { - cout << " " << (char)('a' + edges[i].first) << "-" << (char)('a' + edges[i].second) << ": " << G[edge(edges[i].first, edges[i].second, G).first] << endl; + std::cout << " " << (char)('a' + edges[i].first) << "-" << (char)('a' + edges[i].second) << ": " << G[edge(edges[i].first, edges[i].second, G).first] << std::endl; } return 0; diff --git a/example/edge_property.cpp b/example/edge_property.cpp index fd041c87..46bac1ab 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -57,7 +57,6 @@ using namespace boost; -using namespace std; enum edge_myflow_t { edge_myflow }; @@ -84,21 +83,20 @@ void print_network(const Graph& G) for (; ui != uiend; ++ui) { OutEdgeIter out, out_end; - cout << *ui << "\t"; + std::cout << *ui << "\t"; boost::tie(out, out_end) = out_edges(*ui, G); for(; out != out_end; ++out) - cout << "--(" << capacity[*out] << ", " << flow[*out] << ")--> " + std::cout << "--(" << capacity[*out] << ", " << flow[*out] << ")--> " << target(*out,G) << "\t"; InEdgeIter in, in_end; - cout << endl << "\t"; boost::tie(in, in_end) = in_edges(*ui, G); for(; in != in_end; ++in) - cout << "<--(" << capacity[*in] << "," << flow[*in] << ")-- " + std::cout << "<--(" << capacity[*in] << "," << flow[*in] << ")-- " << source(*in,G) << "\t"; - cout << endl; + std::cout << std::endl; } } @@ -150,7 +148,7 @@ int main(int , char* []) for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v) for (boost::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) flow[*e] = ++f; - cout << endl << endl; + std::cout << std::endl << std::endl; remove_edge(6, 8, G); diff --git a/example/exterior_property_map.cpp b/example/exterior_property_map.cpp index 555142fa..b96389b8 100644 --- a/example/exterior_property_map.cpp +++ b/example/exterior_property_map.cpp @@ -14,7 +14,6 @@ #include #include -using namespace std; using namespace boost; /* @@ -59,8 +58,8 @@ void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G, { while (first != last) { - cout << name[source(*first,G)] << " owes " - << name[target(*first,G)] << " some money" << endl; + std::cout << name[source(*first,G)] << " owes " + << name[target(*first,G)] << " some money" << std::endl; ++first; } } @@ -70,7 +69,7 @@ main(int, char*[]) { /* The property will be "names" attached to the vertices */ - string* names = new string[5]; + std::string* names = new std::string[5]; names[0] = "Jeremy"; names[1] = "Rich"; names[2] = "Andrew"; @@ -79,7 +78,7 @@ main(int, char*[]) using MyGraphType = adjacency_list<>; - using Pair = pair; + using Pair = std::pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index 1d053e51..82ff2145 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -41,7 +41,6 @@ #include #include -using namespace std; using namespace boost; enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp, @@ -57,7 +56,7 @@ const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", struct print_visitor : public bfs_visitor<> { template void discover_vertex(Vertex v, Graph&) { - cout << name[v] << " "; + std::cout << name[v] << " "; } }; @@ -79,7 +78,7 @@ struct cycle_detector : public dfs_visitor<> int main(int,char*[]) { - using Edge = pair; + using Edge = std::pair; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), @@ -114,17 +113,17 @@ int main(int,char*[]) // Determine ordering for a full recompilation // and the order with files that can be compiled in parallel { - using MakeOrder = list; + using MakeOrder = std::list; MakeOrder::iterator i; MakeOrder make_order; topological_sort(g, std::front_inserter(make_order)); - cout << "make ordering: "; + std::cout << "make ordering: "; for (i = make_order.begin(); i != make_order.end(); ++i) - cout << name[*i] << " "; + std::cout << name[*i] << " "; - cout << endl << endl; + std::cout << std::endl << std::endl; // Parallel compilation ordering std::vector time(N, 0); @@ -141,48 +140,48 @@ int main(int,char*[]) } } - cout << "parallel make ordering, " << endl - << "vertices with same group number can be made in parallel" << endl; + std::cout << "parallel make ordering, " << std::endl + << "vertices with same group number can be made in parallel" << std::endl; { graph_traits::vertex_iterator i, iend; for (boost::tie(i,iend) = vertices(g); i != iend; ++i) - cout << "time_slot[" << name[*i] << "] = " << time[*i] << endl; + std::cout << "time_slot[" << name[*i] << "] = " << time[*i] << std::endl; } } - cout << endl; + std::cout << std::endl; // if I change yow.h what files need to be re-made? { - cout << "A change to yow.h will cause what to be re-made?" << endl; + std::cout << "A change to yow.h will cause what to be re-made?" << std::endl; print_visitor vis; breadth_first_search(g, vertex(yow_h, g), visitor(vis)); - cout << endl; + std::cout << std::endl; } - cout << endl; + std::cout << std::endl; // are there any cycles in the graph? { bool has_cycle = false; cycle_detector vis(has_cycle); depth_first_search(g, visitor(vis)); - cout << "The graph has a cycle? " << has_cycle << endl; + std::cout << "The graph has a cycle? " << has_cycle << std::endl; } - cout << endl; + std::cout << std::endl; // add a dependency going from bar.cpp to dax.h { - cout << "adding edge bar_cpp -> dax_h" << endl; + std::cout << "adding edge bar_cpp -> dax_h" << std::endl; add_edge(bar_cpp, dax_h, g); } - cout << endl; + std::cout << std::endl; // are there any cycles in the graph? { bool has_cycle = false; cycle_detector vis(has_cycle); depth_first_search(g, visitor(vis)); - cout << "The graph has a cycle now? " << has_cycle << endl; + std::cout << "The graph has a cycle now? " << has_cycle << std::endl; } return 0; diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index 42a57cee..f6a69fcf 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -19,7 +19,6 @@ #include using namespace boost; -using namespace std; // @@ -31,14 +30,14 @@ struct vertex_label_t { using kind = vertex_property_tag; }; int main() { // Vertex properties - using vertex_p = property>>; // Edge properties - using edge_p = property; + using edge_p = property; // Graph properties - using graph_p = property>; + using graph_p = property>; // adjacency_list-based type using graph_t = adjacency_list; @@ -60,12 +59,12 @@ int main() { dp.property("label",elabel); // Use ref_property_map to turn a graph property into a property map - ref_property_map + ref_property_map gname(get_property(graph,graph_name)); dp.property("name",gname); // Use ref_property_map to turn a graph property into a property map - ref_property_map + ref_property_map gid(get_property(graph,graph_identifier_t())); dp.property("identifier",gid); // Sample graph as an istream; @@ -83,19 +82,19 @@ const char* dot = }"; - istringstream gvgraph(dot); + std::istringstream gvgraph(dot); bool status = read_graphviz(gvgraph,graph,dp,"node_id"); if (!status) { - cerr << "read_graphviz() failed." << endl; + std::cerr << "read_graphviz() failed." << std::endl; return -1; } - cout << "graph " << get("name",dp,&graph) << + std::cout << "graph " << get("name",dp,&graph) << " (" << get("identifier",dp,&graph) << ")\n\n"; BOOST_FOREACH( graph_t::vertex_descriptor v, vertices(graph) ) { - cout << "vertex " << get("node_id",dp,v) << + std::cout << "vertex " << get("node_id",dp,v) << " (" << get("label",dp,v) << ")\n"; } diff --git a/example/graph.cpp b/example/graph.cpp index 04900964..7794b168 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -15,7 +15,6 @@ #include using namespace boost; -using namespace std; using VertexProperty = property "; + std::cout << *i << " --> "; for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - cout << target(*ei, g) << " "; - cout << endl; + std::cout << target(*ei, g) << " "; } } std::size_t myrand(std::size_t N) { std::size_t ret = rand() % N; - // cout << "N = " << N << " rand = " << ret << endl; + // std::cout << "N = " << N << " rand = " << ret << std::endl; return ret; } @@ -68,16 +66,16 @@ int main(int, char*[]) for (i=0; i<6; ++i) { std::size_t a = myrand(N), b = myrand(N); while ( a == b ) b = myrand(N); - cout << "edge edge (" << a << "," << b <<")" << endl; + std::cout << "edge edge (" << a << "," << b <<")" << std::endl; //add edges add_edge(a, b, g); is_failed = is_failed || (! check_edge(g, a, b) ); } if ( is_failed ) - cerr << " Failed."<< endl; + std::cerr << " Failed."<< std::endl; else - cerr << " Passed."<< endl; + std::cerr << " Passed."<< std::endl; print(g); @@ -85,14 +83,14 @@ int main(int, char*[]) for (i = 0; i<2; ++i) { std::size_t a = myrand(N), b = myrand(N); while ( a == b ) b = myrand(N); - cout << "remove edge (" << a << "," << b <<")" << endl; + std::cout << "remove edge (" << a << "," << b <<")" << std::endl; remove_edge(a, b, g); is_failed = is_failed || check_edge(g, a, b); } if ( is_failed ) - cerr << " Failed."<< endl; + std::cerr << " Failed."<< std::endl; else - cerr << " Passed."<< endl; + std::cerr << " Passed."<< std::endl; print(g); @@ -104,26 +102,26 @@ int main(int, char*[]) N = num_vertices(g); if ( (N - 2) != old_N ) - cerr << " Failed."<< endl; + std::cerr << " Failed."<< std::endl; else - cerr << " Passed."<< endl; + std::cerr << " Passed."<< std::endl; is_failed = false; for (i=0; i<2; ++i) { std::size_t a = myrand(N), b = myrand(N); while ( a == vid ) a = myrand(N); while ( b == vidp1 ) b = myrand(N); - cout << "add edge (" << vid << "," << a <<")" << endl; - cout << "add edge (" << vid << "," << vidp1 <<")" << endl; + std::cout << "add edge (" << vid << "," << a <<")" << std::endl; + std::cout << "add edge (" << vid << "," << vidp1 <<")" << std::endl; add_edge(vid, a, g); add_edge(b, vidp1, g); is_failed = is_failed || ! check_edge(g, vid, a); is_failed = is_failed || ! check_edge(g, b, vidp1); } if ( is_failed ) - cerr << " Failed."<< endl; + std::cerr << " Failed."<< std::endl; else - cerr << " Passed."<< endl; + std::cerr << " Passed."<< std::endl; print(g); // clear_vertex @@ -134,7 +132,7 @@ int main(int, char*[]) if ( out_degree(c, g) != 0 ) is_failed = true; - cout << "Removing vertex " << c << endl; + std::cout << "Removing vertex " << c << std::endl; remove_vertex(c, g); old_N = N; @@ -144,9 +142,9 @@ int main(int, char*[]) is_failed = true; if ( is_failed ) - cerr << " Failed."<< endl; + std::cerr << " Failed."<< std::endl; else - cerr << " Passed."<< endl; + std::cerr << " Passed."<< std::endl; print(g); diff --git a/example/graph_property.cpp b/example/graph_property.cpp index a35c0326..73fb32e7 100644 --- a/example/graph_property.cpp +++ b/example/graph_property.cpp @@ -13,11 +13,10 @@ int main() { using namespace boost; - using std::string; using graph_t = adjacency_list, - property>; + property>; graph_t g; get_property(g, graph_name) = "graph"; diff --git a/example/in_edges.cpp b/example/in_edges.cpp index b994d5cd..6cd9c79e 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -27,8 +27,6 @@ int main(int , char* []) { using namespace boost; - using namespace std; - using namespace boost; using Graph = adjacency_list; const int num_vertices = 5; @@ -44,10 +42,9 @@ int main(int , char* []) boost::graph_traits::in_edge_iterator ei, edge_end; for(boost::tie(i,end) = vertices(g); i != end; ++i) { - cout << *i << " <-- "; + std::cout << *i << " <-- "; for (boost::tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) - cout << source(*ei, g) << " "; - cout << endl; + std::cout << source(*ei, g) << " "; } return 0; } diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index 0b1fd09c..c3380819 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -14,7 +14,6 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // This template structure defines the function that we will apply @@ -23,7 +22,7 @@ using namespace boost; template > + typename Divides = std::divides> struct inclusive_average { using distance_type = DistanceType; @@ -45,7 +44,7 @@ struct inclusive_average // represents web pages that can be navigated to. struct WebPage { - string name; + std::string name; }; // The Link type stores an associated probability of traveling @@ -62,7 +61,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. @@ -95,7 +94,7 @@ main(int argc, char *argv[]) WeightMap wm(get(&Link::probability, g)); // Read the weighted graph from standard input. - read_weighted_graph(g, nm, wm, cin); + read_weighted_graph(g, nm, wm, std::cin); // Compute the distances between all pairs of vertices using // the Floyd-Warshall algorithm. The weight map was created @@ -117,18 +116,18 @@ main(int argc, char *argv[]) // Print the mean geodesic distance of each vertex and finally, // the graph itself. - cout << setw(12) << setiosflags(ios::left) << "vertex"; - cout << setw(12) << setiosflags(ios::left) << "excluding"; - cout << setw(12) << setiosflags(ios::left) << "including" << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "vertex"; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "excluding"; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "including" << std::endl; graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) + std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name - << setw(12) << get(exmap, *i) - << setw(12) << get(inmap, *i) << endl; + << std::setw(12) << get(exmap, *i) + << std::setw(12) << get(inmap, *i) << std::endl; } - cout << "small world (excluding self-loops): " << ex << endl; - cout << "small world (including self-loops): " << in << endl; + std::cout << "small world (excluding self-loops): " << ex << std::endl; + std::cout << "small world (including self-loops): " << in << std::endl; return 0; } diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index f6b493bb..0fb51fc3 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -14,13 +14,12 @@ #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -30,7 +29,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a container type for influence and prestige (both // of which are degree centralities) and its corresponding @@ -48,7 +47,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the influence for the graph. CentralityContainer influence(num_vertices(g)); @@ -64,10 +63,10 @@ main(int argc, char *argv[]) graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { auto v = *i; - cout << setiosflags(ios::left) << setw(12) + std::cout << std::setiosflags(std::ios::left) << std::setw(12) << g[v].name << "\t" << im[v] << "\t" - << pm[v] << endl; + << pm[v] << std::endl; } return 0; diff --git a/example/interior_pmap_bundled.cpp b/example/interior_pmap_bundled.cpp index 21e46ab6..08f3dff3 100644 --- a/example/interior_pmap_bundled.cpp +++ b/example/interior_pmap_bundled.cpp @@ -15,7 +15,6 @@ #include #include -using namespace std; using namespace boost; /* @@ -49,15 +48,15 @@ template void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) { while (first != last) { - cout << G[source(*first, G)].first_name << " owes " - << G[target(*first, G)].first_name << " some money" << endl; + std::cout << G[source(*first, G)].first_name << " owes " + << G[target(*first, G)].first_name << " some money" << std::endl; ++first; } } struct VertexData { - string first_name; + std::string first_name; }; int @@ -68,7 +67,7 @@ main() // store the first name's. using MyGraphType = adjacency_list; - using Pair = pair; + using Pair = std::pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; @@ -86,7 +85,7 @@ main() who_owes_who(edges(G).first, edges(G).second, G); } - cout << endl; + std::cout << std::endl; return 0; } diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index bdb870cd..4ea35cf6 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -14,7 +14,6 @@ #include #include -using namespace std; using namespace boost; /* @@ -66,8 +65,8 @@ void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) while (first != last) { src_name = boost::get(name, source(*first,G)); targ_name = boost::get(name, target(*first,G)); - cout << src_name << " owes " - << targ_name << " some money" << endl; + std::cout << src_name << " owes " + << targ_name << " some money" << std::endl; ++first; } } @@ -81,7 +80,7 @@ main() using MyGraphType = adjacency_list>; - using Pair = pair; + using Pair = std::pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; @@ -102,7 +101,7 @@ main() who_owes_who(edges(G).first, edges(G).second, G); } - cout << endl; + std::cout << std::endl; return 0; } diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 06349ab1..5e9aafb8 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -32,7 +32,6 @@ int main(int , char* []) { using namespace boost; - using namespace std; using Graph = adjacency_list>>; @@ -76,12 +75,12 @@ int main(int , char* []) //king_ordering king_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G), get(vertex_index, G)); - cout << "King ordering starting at: " << s << endl; - cout << " "; + std::cout << "King ordering starting at: " << s << std::endl; + std::cout << " "; for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; - cout << endl; + std::cout << index_map[*i] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; @@ -94,11 +93,11 @@ int main(int , char* []) //king_ordering king_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G), get(vertex_index, G)); - cout << "King ordering starting at: " << s << endl; - cout << " "; + std::cout << "King ordering starting at: " << s << std::endl; + std::cout << " "; for (const auto& vertex : inv_perm) - cout << index_map[vertex] << " "; - cout << endl; + std::cout << index_map[vertex] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; @@ -112,11 +111,11 @@ int main(int , char* []) king_ordering(G, inv_perm.rbegin(), get(vertex_color, G), make_degree_map(G), get(vertex_index, G)); - cout << "King ordering:" << endl; - cout << " "; + std::cout << "King ordering:" << std::endl; + std::cout << " "; for (const auto& vertex : inv_perm) - cout << index_map[vertex] << " "; - cout << endl; + std::cout << index_map[vertex] << " "; + std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) perm[index_map[inv_perm[c]]] = c; diff --git a/example/labeled_graph.cpp b/example/labeled_graph.cpp index 0cdd6f7f..4b04e804 100644 --- a/example/labeled_graph.cpp +++ b/example/labeled_graph.cpp @@ -11,7 +11,6 @@ #include using namespace boost; -using namespace std; int main() { @@ -29,14 +28,14 @@ int main() { } { - using Graph = labeled_graph; + using Graph = labeled_graph; Graph g; add_vertex("foo", g); add_vertex("bar", g); } { - using Graph = labeled_graph; + using Graph = labeled_graph; Graph g; add_vertex("foo", g); add_vertex("bar", g); diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index fc98d0b2..606c325c 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -14,13 +14,12 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // The Actor type stores the name of each vertex in the graph. struct Actor { - string name; + std::string name; }; // Declare the graph type and its vertex and edge types. @@ -30,7 +29,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. @@ -57,7 +56,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standad input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the distances between all pairs of vertices using // the Floyd-Warshall algorithm. Note that the weight map is @@ -78,10 +77,10 @@ main(int argc, char *argv[]) // the graph itself. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) - << g[*i].name << get(gm, *i) << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[*i].name << get(gm, *i) << std::endl; } - cout << "small world distance: " << sw << endl; + std::cout << "small world distance: " << sw << std::endl; return 0; diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index b8e786fe..448e705c 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -86,11 +86,10 @@ struct harwell_boeing int main(int argc, char* argv[]) { - using namespace std; using namespace boost; if (argc < 2) { - cout << argv[0] << " HB file" << endl; + std::cout << argv[0] << " HB file" << std::endl; return -1; } @@ -106,7 +105,7 @@ int main(int argc, char* argv[]) int n = hbs.nrows(); - cout << "n is " << n << endl; + std::cout << "n is " << n << std::endl; Graph G(n); @@ -120,7 +119,7 @@ int main(int argc, char* argv[]) num_edge++; } - cout << "number of off-diagnal elements: " << num_edge << endl; + std::cout << "number of off-diagnal elements: " << num_edge << std::endl; using Vector = std::vector; @@ -142,9 +141,9 @@ int main(int argc, char* argv[]) delta, id); if ( argc >= 3 ) { - ifstream input(argv[2]); + std::ifstream input(argv[2]); if ( input.fail() ) { - cout << argv[3] << " is failed to open!. " << endl; + std::cout << argv[3] << " is failed to open!. " << std::endl; return -1; } int comp; @@ -153,24 +152,24 @@ int main(int argc, char* argv[]) for ( i=0; i> comp; if ( comp != inverse_perm[i]+1 ) { - cout << "at i= " << i << ": " << comp - << " ***is NOT EQUAL to*** " << inverse_perm[i]+1 << endl; + std::cout << "at i= " << i << ": " << comp + << " ***is NOT EQUAL to*** " << inverse_perm[i]+1 << std::endl; is_correct = false; } } for ( i=0; i> comp; if ( comp != perm[i]+1 ) { - cout << "at i= " << i << ": " << comp - << " ***is NOT EQUAL to*** " << perm[i]+1 << endl; + std::cout << "at i= " << i << ": " << comp + << " ***is NOT EQUAL to*** " << perm[i]+1 << std::endl; is_correct = false; } } if ( is_correct ) - cout << "Permutation and inverse permutation are correct. "<< endl; + std::cout << "Permutation and inverse permutation are correct. "<< std::endl; else - cout << "WARNING -- Permutation or inverse permutation is not the " - << "same ones generated by Liu's " << endl; + std::cout << "WARNING -- Permutation or inverse permutation is not the " + << "same ones generated by Liu's " << std::endl; } return 0; diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index bd7730fb..0c2f0477 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -16,7 +16,6 @@ #include using namespace boost; -using namespace std; int main() { // Vertex properties diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index 0355ff3b..3da40098 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -14,7 +14,6 @@ #include #include "helper.hpp" -using namespace std; using namespace boost; // This template struct provides a generic version of a "scaling" @@ -26,7 +25,7 @@ using namespace boost; template > + typename Divide = std::divides> struct scaled_closeness_measure { using distance_type = Distance; @@ -57,7 +56,7 @@ using Edge = graph_traits::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -using NameMap = property_map::type; +using NameMap = property_map::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. @@ -84,7 +83,7 @@ main(int argc, char *argv[]) NameMap nm(get(&Actor::name, g)); // Read the graph from standard input. - read_graph(g, nm, cin); + read_graph(g, nm, std::cin); // Compute the distances between all pairs of vertices using // the Floyd-Warshall algorithm. Note that the weight map is @@ -105,8 +104,8 @@ main(int argc, char *argv[]) // Print the scaled closeness centrality of each vertex. graph_traits::vertex_iterator i, end; for(boost::tie(i, end) = vertices(g); i != end; ++i) { - cout << setw(12) << setiosflags(ios::left) - << g[*i].name << get(cm, *i) << endl; + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[*i].name << get(cm, *i) << std::endl; } return 0; diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index a87c936e..3eabb4f8 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -20,10 +20,6 @@ #include #include - -using std::cout; -using std::endl; - /* Sample Output ##################################### @@ -63,13 +59,12 @@ using std::endl; int main(int , char* []) { - cout << endl; - cout << "#####################################" << endl; - cout << "### First light of sloan-ordering ###" << endl; - cout << "#####################################" << endl << endl; + std::cout << std::endl; + std::cout << "#####################################" << std::endl; + std::cout << "### First light of sloan-ordering ###" << std::endl; + std::cout << "#####################################" << std::endl << std::endl; using namespace boost; - using namespace std; //Defining the graph type @@ -145,10 +140,10 @@ int main(int , char* []) //Calculating the pseudoeperipheral node and radius Vertex e = pseudo_peripheral_pair(G, s, ecc, get(vertex_color, G), get(vertex_degree, G) ); - cout << endl; - cout << "Starting vertex: " << s << endl; - cout << "Pseudoperipheral vertex: " << e << endl; - cout << "Pseudoperipheral radius: " << ecc << endl << endl; + std::cout << std::endl; + std::cout << "Starting vertex: " << s << std::endl; + std::cout << "Pseudoperipheral vertex: " << e << std::endl; + std::cout << "Pseudoperipheral radius: " << ecc << std::endl << std::endl; @@ -156,13 +151,13 @@ int main(int , char* []) sloan_ordering(G, s, e, sloan_order.begin(), get(vertex_color, G), get(vertex_degree, G), get(vertex_priority, G)); - cout << "Sloan ordering starting at: " << s << endl; - cout << " "; + std::cout << "Sloan ordering starting at: " << s << std::endl; + std::cout << " "; for (auto i = sloan_order.begin(); i != sloan_order.end(); ++i) - cout << index_map[*i] << " "; - cout << endl; + std::cout << index_map[*i] << " "; + std::cout << std::endl; for (size_type c = 0; c != sloan_order.size(); ++c) perm[index_map[sloan_order[c]]] = c; @@ -197,12 +192,12 @@ int main(int , char* []) make_degree_map(G), get(vertex_priority, G) ); - cout << endl << "Sloan ordering without a start-vertex:" << endl; - cout << " "; + std::cout << std::endl << "Sloan ordering without a start-vertex:" << std::endl; + std::cout << " "; for (auto i=sloan_order.begin(); i != sloan_order.end(); ++i) - cout << index_map[*i] << " "; - cout << endl; + std::cout << index_map[*i] << " "; + std::cout << std::endl; for (size_type c = 0; c != sloan_order.size(); ++c) perm[index_map[sloan_order[c]]] = c; @@ -225,10 +220,10 @@ int main(int , char* []) - cout << endl; - cout << "###############################" << endl; - cout << "### sloan-ordering finished ###" << endl; - cout << "###############################" << endl << endl; + std::cout << std::endl; + std::cout << "###############################" << std::endl; + std::cout << "### sloan-ordering finished ###" << std::endl; + std::cout << "###############################" << std::endl << std::endl; return 0; } diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index 759bd3c8..f0850ebe 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -22,9 +22,7 @@ struct edge_t // A graphic of the min-cut is available at int main() -{ - using namespace std; - +{ using undirected_graph = boost::adjacency_list>; using weight_map_type = boost::property_map::type; @@ -49,23 +47,23 @@ int main() // run the Stoer-Wagner algorithm to obtain the min-cut weight. `parities` is also filled in. int w = boost::stoer_wagner_min_cut(g, get(boost::edge_weight, g), boost::parity_map(parities)); - cout << "The min-cut weight of G is " << w << ".\n" << endl; + std::cout << "The min-cut weight of G is " << w << ".\n" << std::endl; assert(w == 7); - cout << "One set of vertices consists of:" << endl; + std::cout << "One set of vertices consists of:" << std::endl; size_t i; for (i = 0; i < num_vertices(g); ++i) { if (get(parities, i)) - cout << i << endl; + std::cout << i << std::endl; } - cout << endl; + std::cout << std::endl; - cout << "The other set of vertices consists of:" << endl; + std::cout << "The other set of vertices consists of:" << std::endl; for (i = 0; i < num_vertices(g); ++i) { if (!get(parities, i)) - cout << i << endl; + std::cout << i << std::endl; } - cout << endl; + std::cout << std::endl; return EXIT_SUCCESS; } diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index 93bd13e8..32e30313 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -12,7 +12,6 @@ #include "helper.hpp" -using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. @@ -25,15 +24,15 @@ main(int argc, char *argv[]) { // Create the graph and read it from standard input. Graph g; - read_graph(g, cin); + read_graph(g, std::cin); // Compute the girth and circumference simulataneously size_t girth, circ; boost::tie(girth, circ) = tiernan_girth_and_circumference(g); // Print the result - cout << "girth: " << girth << endl; - cout << "circumference: " << circ << endl; + std::cout << "girth: " << girth << std::endl; + std::cout << "circumference: " << circ << std::endl; return 0; } diff --git a/example/tiernan_print_cycles.cpp b/example/tiernan_print_cycles.cpp index 2909b59c..b8b5e772 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -12,7 +12,6 @@ #include "helper.hpp" -using namespace std; using namespace boost; // The cycle_printer is a visitor that will print the path that comprises @@ -38,7 +37,7 @@ struct cycle_printer for(i = p.begin(); i != end; ++i) { os << get(indices, *i) << " "; } - os << endl; + os << std::endl; } OutputStream& os; }; @@ -53,10 +52,10 @@ main(int argc, char *argv[]) { // Create the graph and read it from standard input. Graph g; - read_graph(g, cin); + read_graph(g, std::cin); // Instantiate the visitor for printing cycles - cycle_printer vis(cout); + cycle_printer vis(std::cout); // Use the Tiernan algorithm to visit all cycles, printing them // as they are found. diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index a089c706..6846349b 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -14,9 +14,6 @@ #include #include - -using namespace std; - using Graph = boost::adjacency_list < @@ -45,7 +42,7 @@ boost::graph_traits::edge_iterator; int main(int argc, char **argv) { Graph iG, vG; - vector iG_o = { + std::vector iG_o = { boost::add_edge(0, 1, iG).first, boost::add_edge(0, 2, iG).first, boost::add_edge(0, 3, iG).first, @@ -53,7 +50,7 @@ int main(int argc, char **argv) boost::add_edge(1, 2, iG).first, boost::add_edge(3, 4, iG).first}; - vector vG_o= { + std::vector vG_o= { boost::add_edge(1, 2, vG).first, boost::add_edge(2, 0, vG).first, boost::add_edge(2, 3, vG).first, @@ -61,7 +58,7 @@ int main(int argc, char **argv) boost::add_edge(0, 3, vG).first, boost::add_edge(0, 4, vG).first}; - vector inL(iG_o.size(), false); + std::vector inL(iG_o.size(), false); std::vector> coll; boost::tree_collector< diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index 12ce5d65..b1dc34d9 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -12,7 +12,6 @@ #include #include -using namespace std; using namespace boost; @@ -68,7 +67,7 @@ struct print_edge { auto src = source(e, G); auto targ = target(e, G); - cout << "(" << id[src] << "," << id[targ] << ") "; + std::cout << "(" << id[src] << "," << id[targ] << ") "; } Graph& G; @@ -83,7 +82,7 @@ struct print_index { { typename boost::property_map::type id = get(vertex_index, G); - cout << id[c] << " "; + std::cout << id[c] << " "; } Graph& G; @@ -101,24 +100,24 @@ struct exercise_vertex { typename boost::property_map::type id = get(vertex_index, g); - cout << "vertex id: " << id[v] << endl; + std::cout << "vertex id: " << id[v] << std::endl; - cout << "out-edges: "; - for_each(out_edges(v, g).first, out_edges(v,g).second, + std::cout << "out-edges: "; + std::for_each(out_edges(v, g).first, out_edges(v,g).second, print_edge(g)); - cout << endl; + std::cout << std::endl; - cout << "in-edges: "; - for_each(in_edges(v, g).first, in_edges(v,g).second, + std::cout << "in-edges: "; + std::for_each(in_edges(v, g).first, in_edges(v,g).second, print_edge(g)); - cout << endl; + std::cout << std::endl; - cout << "adjacent vertices: "; - for_each(adjacent_vertices(v,g).first, + std::cout << "adjacent vertices: "; + std::for_each(adjacent_vertices(v,g).first, adjacent_vertices(v,g).second, print_index(g)); - cout << endl << endl; + std::cout << std::endl << std::endl; } Graph& g; @@ -130,7 +129,7 @@ main() { using MyGraphType = adjacency_list; - using Pair = pair; + using Pair = std::pair; Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; @@ -143,7 +142,7 @@ main() boost::property_map::type id = get(vertex_index, g); - cout << "vertices(g) = "; + std::cout << "vertices(g) = "; boost::graph_traits::vertex_iterator vi; for (vi = vertices(g).first; vi != vertices(g).second; ++vi) std::cout << id[*vi] << " "; @@ -151,7 +150,7 @@ main() /* Use the STL for_each algorithm to "exercise" all of the vertices in the graph */ - for_each(vertices(g).first, vertices(g).second, + std::for_each(vertices(g).first, vertices(g).second, exercise_vertex(g)); return 0; diff --git a/example/visitor.cpp b/example/visitor.cpp index 4a87a4d8..ae2f259e 100644 --- a/example/visitor.cpp +++ b/example/visitor.cpp @@ -45,7 +45,6 @@ #include using namespace boost; -using namespace std; template struct edge_printer : public base_visitor> { @@ -83,14 +82,14 @@ main(int, char*[]) std::vector d(num_vertices(G)); std::vector f(num_vertices(G)); - cout << "DFS categorized directed graph" << endl; + std::cout << "DFS categorized directed graph" << std::endl; depth_first_search(G, visitor(make_dfs_visitor( make_list(print_edge("tree", on_tree_edge()), print_edge("back", on_back_edge()), print_edge("forward or cross", on_forward_or_cross_edge()) )))); - cout << endl << "BFS categorized directed graph" << endl; + std::cout << std::endl << "BFS categorized directed graph" << std::endl; boost::breadth_first_search (G, vertex(0, G), visitor(make_bfs_visitor( std::make_pair(print_edge("tree", on_tree_edge()), From e38642db115f17620bb3e5d2bdac5370afe611f8 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 May 2016 16:32:19 +0200 Subject: [PATCH 14/28] examples: C++11: Use std::tie() instead of boost::tie(). --- example/accum-compile-times.cpp | 4 ++-- example/adjacency_list.cpp | 10 +++++----- example/astar-cities.cpp | 2 +- example/bellman-example.cpp | 4 ++-- example/bfs-example2.cpp | 2 +- example/bfs-name-printer.cpp | 14 +++++++------- example/biconnected_components.cpp | 2 +- example/bipartite_example.cpp | 2 +- example/boost_web_graph.cpp | 14 +++++++------- example/boykov_kolmogorov-eg.cpp | 4 ++-- example/canonical_ordering.cpp | 2 +- example/cc-internet.cpp | 2 +- example/closeness_centrality.cpp | 2 +- example/clustering_coefficient.cpp | 2 +- example/components_on_edgelist.cpp | 1 - example/copy-example.cpp | 2 +- example/cuthill_mckee_ordering.cpp | 2 +- example/cycle-file-dep.cpp | 8 ++++---- example/cycle-file-dep2.cpp | 8 ++++---- example/cycle_ratio_example.cpp | 2 +- example/dag_shortest_paths.cpp | 2 +- example/dave.cpp | 4 ++-- example/degree_centrality.cpp | 2 +- example/dfs-parenthesis.cpp | 2 +- example/dijkstra-example-listS.cpp | 6 +++--- example/dijkstra-example.cpp | 4 ++-- example/dijkstra-no-color-map-example.cpp | 4 ++-- example/eccentricity.cpp | 4 ++-- example/edge-connectivity.cpp | 16 ++++++++-------- example/edge-function.cpp | 8 ++++---- example/edge_iterator_constructor.cpp | 2 +- example/edge_property.cpp | 10 +++++----- example/edmonds-karp-eg.cpp | 4 ++-- example/exterior_properties.cpp | 6 +++--- example/family_tree.cpp | 4 ++-- example/file_dependencies.cpp | 6 +++--- example/filtered-copy-example.cpp | 2 +- example/filtered_graph_edge_range.cpp | 4 ++-- example/fr_layout.cpp | 2 +- example/gerdemann.cpp | 12 ++++++------ example/girth.cpp | 2 +- example/graph-property-iter-eg.cpp | 4 ++-- example/graph.cpp | 6 +++--- example/helper.hpp | 2 +- example/implicit_graph.cpp | 10 +++++----- example/in_edges.cpp | 4 ++-- example/inclusive_mean_geodesic.cpp | 2 +- example/incremental_components.cpp | 8 ++++---- example/influence_prestige.cpp | 2 +- example/isomorphism.cpp | 4 ++-- example/johnson-eg.cpp | 4 ++-- example/kevin-bacon.cpp | 8 ++++---- example/kevin-bacon2.cpp | 4 ++-- example/king_ordering.cpp | 2 +- example/knights_tour.cpp | 20 ++++++++++---------- example/kruskal-example.cpp | 4 ++-- example/kruskal-telephone.cpp | 2 +- example/kuratowski_subgraph.cpp | 2 +- example/leda-graph-eg.cpp | 2 +- example/loops_dfs.cpp | 8 ++++---- example/make_biconnected_planar.cpp | 4 ++-- example/make_maximal_planar.cpp | 6 +++--- example/matching_example.cpp | 4 ++-- example/max_flow.cpp | 4 ++-- example/mean_geodesic.cpp | 2 +- example/min_max_paths.cpp | 6 +++--- example/modify_graph.cpp | 26 +++++++++++++------------- example/ordered_out_edges.cpp | 8 ++++---- example/ospf-example.cpp | 6 +++--- example/parallel-compile-time.cpp | 22 +++++++++++----------- example/planar_face_traversal.cpp | 2 +- example/prim-example.cpp | 2 +- example/prim-telephone.cpp | 2 +- example/print-adjacent-vertices.cpp | 4 ++-- example/print-edges.cpp | 2 +- example/print-in-edges.cpp | 4 ++-- example/print-out-edges.cpp | 4 ++-- example/push-relabel-eg.cpp | 4 ++-- example/quick-tour.cpp | 16 ++++++++-------- example/quick_tour.cpp | 12 ++++++------ example/reachable-loop-head.cpp | 6 +++--- example/reachable-loop-tail.cpp | 4 ++-- example/read_write_dimacs-eg.cpp | 4 ++-- example/remove_edge_if_bidir.cpp | 2 +- example/remove_edge_if_undir.cpp | 2 +- example/roget_components.cpp | 6 +++--- example/scaled_closeness_centrality.cpp | 2 +- example/scc.cpp | 2 +- example/sloan_ordering.cpp | 2 +- example/straight_line_drawing.cpp | 2 +- example/subgraph.cpp | 2 +- example/tiernan_girth_circumference.cpp | 2 +- example/topo-sort-file-dep.cpp | 8 ++++---- example/topo-sort-file-dep2.cpp | 8 ++++---- example/transpose-example.cpp | 4 ++-- example/undirected_adjacency_list.cpp | 14 +++++++------- 96 files changed, 251 insertions(+), 252 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index df73f2cf..853bc2e3 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -74,14 +74,14 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; } graph_property_iter_range < file_dep_graph2, vertex_compile_cost_t >::iterator ci, ci_end; - boost::tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost); + std::tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost); std::cout << "total (sequential) compile time: " << std::accumulate(ci, ci_end, 0.0) << std::endl; diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index b1ee5348..cd1969cc 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -64,7 +64,7 @@ int main(int , char* []) boost::graph_traits::vertex_iterator vi, viend; int vnum = 0; - for (boost::tie(vi,viend) = vertices(g); vi != viend; ++vi) + for (std::tie(vi,viend) = vertices(g); vi != viend; ++vi) id[*vi] = vnum++; add_edge(vertex(0, g), vertex(1, g), EdgeProperties("joe"), g); @@ -75,9 +75,9 @@ int main(int , char* []) graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; - for (boost::tie(i,end) = vertices(g); i != end; ++i) { + for (std::tie(i,end) = vertices(g); i != end; ++i) { std::cout << id[*i] << " "; - for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; } print_edges(g, id); @@ -90,9 +90,9 @@ int main(int , char* []) << "," << id[target(*ei, g)] << ")" << std::endl; remove_edge(ei, g); - for(boost::tie(i,end) = vertices(g); i != end; ++i) { + for(std::tie(i,end) = vertices(g); i != end; ++i) { std::cout << id[*i] << " "; - for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; std::cout << std::endl; } diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 30e658bb..20c7af0c 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -162,7 +162,7 @@ int main(int argc, char **argv) auto weightmap = get(edge_weight, g); for(std::size_t j = 0; j < num_edges; ++j) { edge_descriptor e; bool inserted; - boost::tie(e, inserted) = add_edge(edge_array[j].first, + std::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index 84db1b41..cea3639f 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -72,7 +72,7 @@ main() graph_traits::edge_iterator ei, ei_end; auto weight_pmap = get(&EdgeProperties::weight, g); int i = 0; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) weight_pmap[*ei] = weight[i]; std::vector distance(N, (std::numeric_limits::max)()); @@ -106,7 +106,7 @@ main() << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; { - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { auto e = *ei; auto u = source(e, g), v = target(e, g); // VC++ doesn't like the 3-argument get function, so here diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index c8ea003c..5e13b442 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -81,7 +81,7 @@ main() property_map::type>; graph_traits::vertex_iterator vi, vi_end; std::size_t c = 0; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) { dtime[c] = dtime_map[*vi]; put(&VertexProps::index, g, *vi, c); } diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index 1ba1ee5f..7c98b816 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -31,19 +31,19 @@ build_router_network(Graph & g, VertexNameMap name_map, typename graph_traits::edge_descriptor ed; bool inserted; - boost::tie(ed, inserted) = add_edge(a, b, g); + std::tie(ed, inserted) = add_edge(a, b, g); delay_map[ed] = 1.2; - boost::tie(ed, inserted) = add_edge(a, d, g); + std::tie(ed, inserted) = add_edge(a, d, g); delay_map[ed] = 4.5; - boost::tie(ed, inserted) = add_edge(b, d, g); + std::tie(ed, inserted) = add_edge(b, d, g); delay_map[ed] = 1.8; - boost::tie(ed, inserted) = add_edge(c, a, g); + std::tie(ed, inserted) = add_edge(c, a, g); delay_map[ed] = 2.6; - boost::tie(ed, inserted) = add_edge(c, e, g); + std::tie(ed, inserted) = add_edge(c, e, g); delay_map[ed] = 5.2; - boost::tie(ed, inserted) = add_edge(d, c, g); + std::tie(ed, inserted) = add_edge(d, c, g); delay_map[ed] = 0.4; - boost::tie(ed, inserted) = add_edge(d, e, g); + std::tie(ed, inserted) = add_edge(d, e, g); delay_map[ed] = 3.3; } diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 4654807b..0234740c 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -62,7 +62,7 @@ main() } graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) std::cout << (char)(source(*ei, g) + 'A') << " -- " << (char)(target(*ei, g) + 'A') << "[label=\"" << component[*ei] << "\"]\n"; diff --git a/example/bipartite_example.cpp b/example/bipartite_example.cpp index 507202db..26c49838 100644 --- a/example/bipartite_example.cpp +++ b/example/bipartite_example.cpp @@ -41,7 +41,7 @@ void print_bipartite (const Graph& g) is_bipartite (g, get (vertex_index, g), partition_map); - for (boost::tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter) + for (std::tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter) { std::cout << "Vertex " << *vertex_iter << " has color " << (get (partition_map, *vertex_iter) == color_traits < default_color_type>::white () ? "white" : "black") << std::endl; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index ba82eafb..e59cba31 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -114,7 +114,7 @@ main() auto i = line_toks.begin(); - boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); + std::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { u = add_vertex(g); put(node_name, u, *i); @@ -125,7 +125,7 @@ main() std::string hyperlink_name = *i++; - boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); + std::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { v = add_vertex(g); put(node_name, v, *i); @@ -134,7 +134,7 @@ main() v = pos->second; Edge e; - boost::tie(e, inserted) = add_edge(u, v, g); + std::tie(e, inserted) = add_edge(u, v, g); if (inserted) { put(link_name, e, hyperlink_name); } @@ -168,7 +168,7 @@ main() std::cout << "Number of clicks from the home page: " << std::endl; Traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << d_matrix[0][*vi] << "\t" << node_name[*vi] << std::endl; std::cout << std::endl; @@ -177,7 +177,7 @@ main() // Create storage for a mapping from vertices to their parents std::vector parent(num_vertices(g)); - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) parent[*vi] = *vi; // Do a BFS starting at the home page, recording the parent of each @@ -190,7 +190,7 @@ main() // Add all the search tree edges into a new graph Graph search_tree(num_vertices(g)); - boost::tie(vi, vi_end) = vertices(g); + std::tie(vi, vi_end) = vertices(g); ++vi; for (; vi != vi_end; ++vi) add_edge(parent[*vi], *vi, search_tree); @@ -205,7 +205,7 @@ main() using NameMap = property_map::type; print_tree_visitor tree_printer(node_name, &dfs_distances[0]); - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) get(vertex_color, g)[*vi] = white_color; depth_first_visit(search_tree, src, tree_printer, get(vertex_color, g)); diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index 2258f664..31cc70de 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -99,8 +99,8 @@ int main() std::cout << "c flow values:" << std::endl; graph_traits::vertex_iterator u_iter, u_end; graph_traits::out_edge_iterator ei, e_end; - for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index 3ab48a5a..f959d384 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -50,7 +50,7 @@ int main(int argc, char** argv) auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); diff --git a/example/cc-internet.cpp b/example/cc-internet.cpp index a1e83cb7..b5764d37 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -29,7 +29,7 @@ main() std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; if (vertex_attr_map[*vi]["color"] == "black") diff --git a/example/closeness_centrality.cpp b/example/closeness_centrality.cpp index aec94ed7..8e842425 100644 --- a/example/closeness_centrality.cpp +++ b/example/closeness_centrality.cpp @@ -74,7 +74,7 @@ main(int argc, char *argv[]) // Print the closeness centrality of each vertex. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << get(cm, *i) << std::endl; } diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index 39e89584..97904480 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -57,7 +57,7 @@ main(int argc, char *argv[]) // Print the clustering coefficient of each vertex. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << get(cm, *i) << std::endl; } diff --git a/example/components_on_edgelist.cpp b/example/components_on_edgelist.cpp index 852c3533..d9ba92ba 100644 --- a/example/components_on_edgelist.cpp +++ b/example/components_on_edgelist.cpp @@ -49,7 +49,6 @@ */ -using boost::tie; int main(int , char* []) { diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 5cd5a48e..9f87c73a 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -24,7 +24,7 @@ main() auto name_map = get(vertex_name, G); char name = 'a'; graph_traits::vertex_iterator v, v_end; - for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; using E = std::pair; diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 9daa51a8..9d436bea 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -61,7 +61,7 @@ int main(int , char* []) graph_traits::vertex_iterator ui, ui_end; auto deg = get(vertex_degree, G); - for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); auto index_map = get(vertex_index, G); diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index 4fd4ee46..1c55e12a 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -38,7 +38,7 @@ has_cycle_dfs(const file_dep_graph & g, vertex_t u, { color[u] = gray_color; graph_traits::adjacency_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (color[*vi] == white_color) { if (has_cycle_dfs(g, *vi, color)) return true; // cycle detected, return immediately @@ -53,7 +53,7 @@ has_cycle(const file_dep_graph & g) { std::vector color(num_vertices(g), white_color); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (color[*vi] == white_color) if (has_cycle_dfs(g, *vi, &color[0])) return true; @@ -74,7 +74,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - boost::tie(i, j) = *input_begin++; + std::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -84,7 +84,7 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; assert(has_cycle(g) == false); diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index f2f6effe..44535745 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -42,7 +42,7 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, color[u] = gray_color; vis.discover_vertex(u, g); graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); dfs_v1(g, target(*ei, g), color, vis); @@ -60,7 +60,7 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector color(num_vertices(g), white_color); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); } @@ -131,7 +131,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - boost::tie(i, j) = *input_begin++; + std::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -141,7 +141,7 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; assert(has_cycle(g) == false); diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index cb13bce6..6a2d63a1 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) std::cout << "Edges number: " << num_edges(tgr) << std::endl; int i = 0; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { + for (std::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { vim[*vi] = i++; ///Initialize vertex index property } max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 0396c815..f0878767 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -59,7 +59,7 @@ int main() #endif graph_traits::vertex_iterator vi , vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (d_map[*vi] == (std::numeric_limits::max)()) std::cout << name[*vi] << ": inifinity\n"; else diff --git a/example/dave.cpp b/example/dave.cpp index 3d6eedc0..6d824cfc 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -142,10 +142,10 @@ template void print(Graph& G, Name name) { typename boost::graph_traits::vertex_iterator ui, uiend; - for (boost::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) { + for (std::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) { std::cout << name[*ui] << " --> "; typename boost::graph_traits::adjacency_iterator vi, viend; - for(boost::tie(vi, viend) = adjacent_vertices(*ui, G); vi != viend; ++vi) + for(std::tie(vi, viend) = adjacent_vertices(*ui, G); vi != viend; ++vi) std::cout << name[*vi] << " "; } } diff --git a/example/degree_centrality.cpp b/example/degree_centrality.cpp index 6ba33b41..918c6334 100644 --- a/example/degree_centrality.cpp +++ b/example/degree_centrality.cpp @@ -56,7 +56,7 @@ main(int argc, char *argv[]) // Print the degree centrality of each vertex. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setiosflags(std::ios::left) << std::setw(12) << g[*i].name << cm[*i] << std::endl; } diff --git a/example/dfs-parenthesis.cpp b/example/dfs-parenthesis.cpp index 5c38d83e..a723f9c5 100644 --- a/example/dfs-parenthesis.cpp +++ b/example/dfs-parenthesis.cpp @@ -36,7 +36,7 @@ main() GraphvizGraph g; read_graphviz("figs/dfs-example.dot", g); graph_traits::edge_iterator e, e_end; - for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) + for (std::tie(e, e_end) = edges(g); e != e_end; ++e) std::cout << '(' << name[source(*e, g)] << ' ' << name[target(*e, g)] << ')' << std::endl; parenthesis_visitor diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 2713dc9c..ac7a5563 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -44,7 +44,7 @@ main(int, char *[]) auto indexmap = get(vertex_index, g); auto name = get(vertex_name, g); int c = 0; - for (boost::tie(i, iend) = vertices(g); i != iend; ++i, ++c) { + for (std::tie(i, iend) = vertices(g); i != iend; ++i, ++c) { indexmap[*i] = c; name[*i] = 'A' + c; } @@ -57,7 +57,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits::vertex_iterator vi, vend; - for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } @@ -71,7 +71,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { auto e = *ei; auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index c7384e74..153832f2 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -44,7 +44,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits::vertex_iterator vi, vend; - for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } @@ -59,7 +59,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { auto e = *ei; auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index b13fc848..b183e292 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -48,7 +48,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits::vertex_iterator vi, vend; - for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; } @@ -63,7 +63,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits::edge_descriptor e = *ei; auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index f15c97f2..a30b3833 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -72,11 +72,11 @@ main(int argc, char *argv[]) int r, d; EccentricityContainer eccs(num_vertices(g)); EccentricityMap em(eccs, g); - boost::tie(r, d) = all_eccentricities(g, dm, em); + std::tie(r, d) = all_eccentricities(g, dm, em); // Print the closeness centrality of each vertex. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << get(em, *i) << std::endl; } diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index db67fb07..cd56a4e8 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -24,7 +24,7 @@ namespace boost using size_type = typename graph_traits < Graph >::degree_size_type; auto delta = (std::numeric_limits < size_type >::max)(); typename graph_traits < Graph >::vertex_iterator i, iend; - for (boost::tie(i, iend) = vertices(g); i != iend; ++i) + for (std::tie(i, iend) = vertices(g); i != iend; ++i) if (degree(*i, g) < delta) { delta = degree(*i, g); @@ -39,7 +39,7 @@ namespace boost OutputIterator result) { typename graph_traits::adjacency_iterator ai, aend; - for (boost::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) + for (std::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) *result++ = *ai; } template < typename Graph, typename VertexIterator, @@ -84,17 +84,17 @@ namespace boost auto rev_edge = get(edge_reverse, flow_g); typename graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { u = source(*ei, g), v = target(*ei, g); - boost::tie(e1, inserted) = add_edge(u, v, flow_g); + std::tie(e1, inserted) = add_edge(u, v, flow_g); cap[e1] = 1; - boost::tie(e2, inserted) = add_edge(v, u, flow_g); + std::tie(e2, inserted) = add_edge(v, u, flow_g); cap[e2] = 1; rev_edge[e1] = e2; rev_edge[e2] = e1; } - boost::tie(p, delta) = min_degree_vertex(g); + std::tie(p, delta) = min_degree_vertex(g); S_star.emplace_back(p); alpha_star = delta; S.insert(p); @@ -112,7 +112,7 @@ namespace boost if (alpha_S_k < alpha_star) { alpha_star = alpha_S_k; S_star.clear(); - for (boost::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) if (color[*vi] != Color::white()) S_star.emplace_back(*vi); } @@ -131,7 +131,7 @@ namespace boost degree_size_type c = 0; for (const auto& vertex : S_star.begin()) { typename graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; ++c; diff --git a/example/edge-function.cpp b/example/edge-function.cpp index c5acf96b..fea0c962 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -43,7 +43,7 @@ output_adjacent_vertices(std::ostream & out, { typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } @@ -107,7 +107,7 @@ main() auto name = get(vertex_name, g); // Get iterators for the vertex set graph_traits::vertex_iterator i, end; - boost::tie(i, end) = vertices(g); + std::tie(i, end) = vertices(g); // Find yow.h using name_map_t = property_map::type; name_equals_t predicate1("yow.h", name); @@ -123,13 +123,13 @@ main() bool exists; // Get the edge connecting yow.h to zag.o - boost::tie(e1, exists) = edge(yow, zag, g); + std::tie(e1, exists) = edge(yow, zag, g); assert(exists == true); assert(source(e1, g) == yow); assert(target(e1, g) == zag); // Discover that there is no edge connecting zag.o to bar.o - boost::tie(e2, exists) = edge(zag, bar, g); + std::tie(e2, exists) = edge(zag, bar, g); assert(exists == false); assert(num_vertices(g) == 15); diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index 4624f5b8..d133f26b 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -107,7 +107,7 @@ main() IteratorConstructibleGraph G(size_V); while (edge_iter != end) { int i, j; - boost::tie(i, j) = *edge_iter++; + std::tie(i, j) = *edge_iter++; boost::add_edge(i, j, G); } #else diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 46bac1ab..a1a2d92a 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -79,19 +79,19 @@ void print_network(const Graph& G) auto flow = get(edge_myflow, G); Viter ui, uiend; - boost::tie(ui, uiend) = vertices(G); + std::tie(ui, uiend) = vertices(G); for (; ui != uiend; ++ui) { OutEdgeIter out, out_end; std::cout << *ui << "\t"; - boost::tie(out, out_end) = out_edges(*ui, G); + std::tie(out, out_end) = out_edges(*ui, G); for(; out != out_end; ++out) std::cout << "--(" << capacity[*out] << ", " << flow[*out] << ")--> " << target(*out,G) << "\t"; InEdgeIter in, in_end; - boost::tie(in, in_end) = in_edges(*ui, G); + std::tie(in, in_end) = in_edges(*ui, G); for(; in != in_end; ++in) std::cout << "<--(" << capacity[*in] << "," << flow[*in] << ")-- " << source(*in,G) << "\t"; @@ -145,8 +145,8 @@ int main(int , char* []) boost::graph_traits::vertex_iterator v, v_end; boost::graph_traits::out_edge_iterator e, e_end; int f = 0; - for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v) - for (boost::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) + for (std::tie(v, v_end) = vertices(G); v != v_end; ++v) + for (std::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) flow[*e] = ++f; std::cout << std::endl << std::endl; diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index ea0fbfb6..68cf7f6c 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -78,8 +78,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits::vertex_iterator u_iter, u_end; graph_traits::out_edge_iterator ei, e_end; - for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index 0085f17b..ae3a8c9e 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -46,17 +46,17 @@ void print_network(Graph& G, Capacity capacity, Flow flow) using InEdgeIter = typename boost::graph_traits::in_edge_iterator; Viter ui, uiend; - for (boost::tie(ui, uiend) = boost::vertices(G); ui != uiend; ++ui) { + for (std::tie(ui, uiend) = boost::vertices(G); ui != uiend; ++ui) { OutEdgeIter out, out_end; std::cout << *ui << "\t"; - for(boost::tie(out, out_end) = boost::out_edges(*ui, G); out != out_end; ++out) + for(std::tie(out, out_end) = boost::out_edges(*ui, G); out != out_end; ++out) std::cout << "--(" << boost::get(capacity, *out) << ", " << boost::get(flow, *out) << ")--> " << boost::target(*out,G) << "\t"; std::cout << std::endl << "\t"; InEdgeIter in, in_end; - for(boost::tie(in, in_end) = boost::in_edges(*ui, G); in != in_end; ++in) + for(std::tie(in, in_end) = boost::in_edges(*ui, G); in != in_end; ++in) std::cout << "<--(" << boost::get(capacity, *in) << "," << boost::get(flow, *in) << ")-- " << boost::source(*in, G) << "\t"; std::cout << std::endl; diff --git a/example/family_tree.cpp b/example/family_tree.cpp index 7aaabccf..03f42135 100644 --- a/example/family_tree.cpp +++ b/example/family_tree.cpp @@ -33,9 +33,9 @@ main() graph_traits>::adjacency_iterator ai, a_end; auto index_map = get(vertex_index, g); - for (boost::tie(i, end) = vertices(g); i != end; ++i) { + for (std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << name[get(index_map, *i)]; - boost::tie(ai, a_end) = adjacent_vertices(*i, g); + std::tie(ai, a_end) = adjacent_vertices(*i, g); if (ai == a_end) std::cout << " has no children"; else diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index 82ff2145..777866b7 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -103,7 +103,7 @@ int main(int,char*[]) Graph g(N); for (std::size_t j = 0; j < nedges; ++j) { graph_traits::edge_descriptor e; bool inserted; - boost::tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g); + std::tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g); } #else Graph g(used_by, used_by + nedges, N); @@ -134,7 +134,7 @@ int main(int,char*[]) int maxdist=0; // Through the order from topological sort, we are sure that every // time we are using here is already initialized. - for (boost::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j) + for (std::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j) maxdist=(std::max)(time[source(*j, g)], maxdist); time[*i]=maxdist+1; } @@ -144,7 +144,7 @@ int main(int,char*[]) << "vertices with same group number can be made in parallel" << std::endl; { graph_traits::vertex_iterator i, iend; - for (boost::tie(i,iend) = vertices(g); i != iend; ++i) + for (std::tie(i,iend) = vertices(g); i != iend; ++i) std::cout << "time_slot[" << name[*i] << "] = " << time[*i] << std::endl; } diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 6375663a..3755325a 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -37,7 +37,7 @@ main() auto name_map = get(vertex_name, G); char name = 'a'; graph_traits::vertex_iterator v, v_end; - for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; using E = std::pair; diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index 4a92688b..2aec7c31 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -61,7 +61,7 @@ int main() std::cout << "unfiltered edge_range(C,D)\n"; graph_traits::out_edge_iterator f, l; - for (boost::tie(f, l) = edge_range(C, D, g); f != l; ++f) + for (std::tie(f, l) = edge_range(C, D, g); f != l; ++f) std::cout << name[source(*f, g)] << " --" << weight[*f] << "-> " << name[target(*f, g)] << "\n"; @@ -71,7 +71,7 @@ int main() std::cout << "filtered edge_range(C,D)\n"; graph_traits::out_edge_iterator first, last; - for (boost::tie(first, last) = edge_range(C, D, fg); first != last; ++first) + for (std::tie(first, last) = edge_range(C, D, fg); first != last; ++first) std::cout << name[source(*first, fg)] << " --" << weight[*first] << "-> " << name[target(*first, fg)] << "\n"; diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 83a79cb8..3fa3e954 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -127,7 +127,7 @@ int main(int argc, char* argv[]) cooling(progress_cooling(iterations))); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { std::cout << get(vertex_name, g, *vi) << '\t' << position[*vi][0] << '\t' << position[*vi][1] << std::endl; } diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index 7fc58506..b0984981 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -46,13 +46,13 @@ void merge_vertex using Traits = boost::graph_traits; typename Traits::edge_descriptor e; typename Traits::out_edge_iterator out_i, out_end; - for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { + for (std::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; auto targ = target(e, g); add_edge(u, targ, getp(e), g); } typename Traits::in_edge_iterator in_i, in_end; - for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { + for (std::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { e = *in_i; auto src = source(e, g); add_edge(src, u, getp(e), g); @@ -127,9 +127,9 @@ main() graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; - for (boost::tie(i, end) = vertices(g); i != end; ++i) { + for (std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << id[*i] << " "; - for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; std::cout << std::endl; } @@ -138,9 +138,9 @@ main() std::cout << "merging vertex 1 into vertex 0" << std::endl << std::endl; merge_vertex(0, 1, g, get_edge_name(g)); - for (boost::tie(i, end) = vertices(g); i != end; ++i) { + for (std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << id[*i] << " "; - for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; std::cout << std::endl; } diff --git a/example/girth.cpp b/example/girth.cpp index 831461f6..cfc8f83e 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -134,7 +134,7 @@ main() c_map = get(color_t(), g); vertex_iterator i, end; - for (boost::tie(i, end) = boost::vertices(g); i != end; ++i) + for (std::tie(i, end) = boost::vertices(g); i != end; ++i) d_map[*i] = 0; std::size_t k = 0; diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index a19ccd4c..3c32c1fa 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -23,11 +23,11 @@ main() const char *vertex_names[] = { "Kubrick", "Clark", "Hal" }; int i = 0; graph_property_iter_range::iterator v, v_end; - for (boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); + for (std::tie(v, v_end) = get_property_iter_range(g, vertex_name); v != v_end; ++v, ++i) *v = vertex_names[i]; - boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); + std::tie(v, v_end) = get_property_iter_range(g, vertex_name); std::copy(v, v_end, std::ostream_iterator (std::cout, " ")); std::cout << std::endl; return 0; diff --git a/example/graph.cpp b/example/graph.cpp index 7794b168..2e0d030e 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -29,9 +29,9 @@ template void print(Graph& g) { typename Graph::vertex_iterator i, end; typename Graph::out_edge_iterator ei, edge_end; - for(boost::tie(i,end) = vertices(g); i != end; ++i) { + for(std::tie(i,end) = vertices(g); i != end; ++i) { std::cout << *i << " --> "; - for (boost::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << target(*ei, g) << " "; } } @@ -45,7 +45,7 @@ std::size_t myrand(std::size_t N) { template bool check_edge(Graph& g, std::size_t a, std::size_t b) { typename Graph::adjacency_iterator vi, viend, found; - boost::tie(vi, viend) = adjacent_vertices(vertex(a,g), g); + std::tie(vi, viend) = adjacent_vertices(vertex(a,g), g); found = find(vi, viend, vertex(b, g)); if ( found == viend ) diff --git a/example/helper.hpp b/example/helper.hpp index 6a019dd8..192e5f6b 100644 --- a/example/helper.hpp +++ b/example/helper.hpp @@ -24,7 +24,7 @@ add_named_vertex(Graph& g, NameMap nm, const std::string& name, VertexMap& vm) Vertex v; Iterator iter; bool inserted; - boost::tie(iter, inserted) = vm.insert(make_pair(name, Vertex())); + std::tie(iter, inserted) = vm.insert(make_pair(name, Vertex())); if(inserted) { // The name was unique so we need to add a vertex to the graph v = add_vertex(g); diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index ba5db765..e09d95a9 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -475,18 +475,18 @@ int main (int argc, char const *argv[]) { // 5 vertices std::cout << "Vertices, outgoing edges, and adjacent vertices" << std::endl; vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; vi++) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; vi++) { vertex_descriptor u = *vi; std::cout << "Vertex " << u << ": "; // Adjacenct edges out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ei++) + for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ei++) std::cout << *ei << " "; std::cout << " Adjacent vertices "; // Adjacent vertices // Here we want our adjacency_iterator and not boost::adjacency_iterator. ::adjacency_iterator ai, ai_end; - for (boost::tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ai++) { + for (std::tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ai++) { std::cout << *ai << " "; } std::cout << std::endl; @@ -505,7 +505,7 @@ int main (int argc, char const *argv[]) { // 5 edges std::cout << "Edges and weights" << std::endl; edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ei++) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ei++) { edge_descriptor e = *ei; std::cout << e << " weight " << get(edge_weight, g, e) << std::endl; } @@ -536,7 +536,7 @@ int main (int argc, char const *argv[]) { distance_map(dist_pm) ); std::cout << "Dijkstra search from vertex " << source << std::endl; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_descriptor u = *vi; std::cout << "Vertex " << u << ": " << "parent "<< pred[*vi] << ", " diff --git a/example/in_edges.cpp b/example/in_edges.cpp index 6cd9c79e..53627c20 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -41,9 +41,9 @@ int main(int , char* []) boost::graph_traits::vertex_iterator i, end; boost::graph_traits::in_edge_iterator ei, edge_end; - for(boost::tie(i,end) = vertices(g); i != end; ++i) { + for(std::tie(i,end) = vertices(g); i != end; ++i) { std::cout << *i << " <-- "; - for (boost::tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) std::cout << source(*ei, g) << " "; } return 0; diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index c3380819..e8a76bb9 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -120,7 +120,7 @@ main(int argc, char *argv[]) std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "excluding"; std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "including" << std::endl; graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << std::setw(12) << get(exmap, *i) diff --git a/example/incremental_components.cpp b/example/incremental_components.cpp index a786f594..32262750 100644 --- a/example/incremental_components.cpp +++ b/example/incremental_components.cpp @@ -70,16 +70,16 @@ int main(int argc, char* argv[]) graph_traits::edge_descriptor edge; bool flag; - boost::tie(edge, flag) = add_edge(0, 1, graph); + std::tie(edge, flag) = add_edge(0, 1, graph); ds.union_set(0,1); - boost::tie(edge, flag) = add_edge(1, 4, graph); + std::tie(edge, flag) = add_edge(1, 4, graph); ds.union_set(1,4); - boost::tie(edge, flag) = add_edge(4, 0, graph); + std::tie(edge, flag) = add_edge(4, 0, graph); ds.union_set(4,0); - boost::tie(edge, flag) = add_edge(2, 5, graph); + std::tie(edge, flag) = add_edge(2, 5, graph); ds.union_set(2,5); std::cout << "An undirected graph:" << std::endl; diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index 0fb51fc3..12c0580b 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -61,7 +61,7 @@ main(int argc, char *argv[]) // Print the degree centrality of each vertex graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { auto v = *i; std::cout << std::setiosflags(std::ios::left) << std::setw(12) << g[v].name << "\t" diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index 84e12b90..d4cb2b42 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -35,12 +35,12 @@ main() graph_traits::vertex_iterator i, end; int id = 0; - for (boost::tie(i, end) = vertices(g1); i != end; ++i, ++id) { + for (std::tie(i, end) = vertices(g1); i != end; ++i, ++id) { put(v1_index_map, *i, id); v1[id] = *i; } id = 0; - for (boost::tie(i, end) = vertices(g2); i != end; ++i, ++id) { + for (std::tie(i, end) = vertices(g2); i != end; ++i, ++id) { put(v2_index_map, *i, id); v2[id] = *i; } diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 44b855d0..e0f6b06c 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -43,7 +43,7 @@ main() int *wp = weights; graph_traits::edge_iterator e, e_end; - for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) + for (std::tie(e, e_end) = edges(g); e != e_end; ++e) w[*e] = *wp++; std::vectord(V, (std::numeric_limits < int>::max)()); @@ -73,7 +73,7 @@ main() << "edge[style=\"bold\"]\n" << "node[shape=\"circle\"]\n"; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) fout << source(*ei, g) << " -> " << target(*ei, g) << "[label=" << get(edge_weight, g)[*ei] << "]\n"; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 1ac22101..3d2091ca 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -73,7 +73,7 @@ main() NameVertexMap::iterator pos; bool inserted; Vertex u, v; - boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex())); + std::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex())); if (inserted) { u = add_vertex(g); actor_name[u] = actors_name; @@ -83,7 +83,7 @@ main() std::string movie_name = *i++; - boost::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex())); + std::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex())); if (inserted) { v = add_vertex(g); actor_name[v] = *i; @@ -92,7 +92,7 @@ main() v = pos->second; graph_traits::edge_descriptor e; - boost::tie(e, inserted) = add_edge(u, v, g); + std::tie(e, inserted) = add_edge(u, v, g); if (inserted) connecting_movie[e] = movie_name; @@ -107,7 +107,7 @@ main() visitor(record_bacon_number(&bacon_number[0]))); graph_traits::vertex_iterator i, end; - for (boost::tie(i, end) = vertices(g); i != end; ++i) { + for (std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << actor_name[*i] << " has a Bacon number of " << bacon_number[*i] << std::endl; } diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index d6ce7814..75b4e862 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -72,7 +72,7 @@ int main() // Get the vertex for Kevin Bacon Vertex src; graph_traits::vertex_iterator i, end; - for (boost::tie(i, end) = vertices(g); i != end; ++i) + for (std::tie(i, end) = vertices(g); i != end; ++i) if (g[*i].name == "Kevin Bacon") src = *i; @@ -83,7 +83,7 @@ int main() breadth_first_search(g, src, visitor(bacon_number_recorder(&bacon_number[0]))); - for (boost::tie(i, end) = vertices(g); i != end; ++i) + for (std::tie(i, end) = vertices(g); i != end; ++i) std::cout << g[*i].name << " has a Bacon number of " << bacon_number[*i] << std::endl; diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 5e9aafb8..da233170 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -61,7 +61,7 @@ int main(int , char* []) graph_traits::vertex_iterator ui, ui_end; auto deg = get(vertex_degree, G); - for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); auto index_map = get(vertex_index, G); diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 68e9becc..cbf7c1f6 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -164,7 +164,7 @@ template S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) @@ -172,7 +172,7 @@ template bool deadend = true; typename graph_traits::adjacency_iterator i, end; - for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { S.push(std::make_pair(time_stamp + 1, *i)); deadend = false; @@ -181,11 +181,11 @@ template if (deadend) { put(time_map, x, -1); S.pop(); - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); } } @@ -198,7 +198,7 @@ number_of_successors(Vertex x, Graph & g, TimePropertyMap time_map) { int s_x = 0; typename graph_traits::adjacency_iterator i, end; - for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) ++s_x; return s_x; @@ -217,7 +217,7 @@ template S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) @@ -227,7 +227,7 @@ template std::priority_queue, compare_first> Q; typename graph_traits::adjacency_iterator i, end; int num_succ; - for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { num_succ = number_of_successors(*i, g, time_map); Q.push(std::make_pair(num_succ, *i)); @@ -235,17 +235,17 @@ template bool deadend = Q.empty(); // move vertices from local priority queue to the stack for (; !Q.empty(); Q.pop()) { - boost::tie(num_succ, x) = Q.top(); + std::tie(num_succ, x) = Q.top(); S.push(std::make_pair(time_stamp + 1, x)); } if (deadend) { put(time_map, x, -1); S.pop(); - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); - boost::tie(time_stamp, x) = S.top(); + std::tie(time_stamp, x) = S.top(); } } diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index e7b49602..cbcc824a 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -30,7 +30,7 @@ main() auto = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { Edge e; bool inserted; - boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + std::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } #else @@ -56,7 +56,7 @@ main() << " ratio=\"filled\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits::edge_iterator eiter, eiter_end; - for (boost::tie(eiter, eiter_end) = edges(g); eiter != eiter_end; ++eiter) { + for (std::tie(eiter, eiter_end) = edges(g); eiter != eiter_end; ++eiter) { fout << source(*eiter, g) << " -- " << target(*eiter, g); if (std::find(spanning_tree.begin(), spanning_tree.end(), *eiter) != spanning_tree.end()) diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index ac9219eb..7076bfab 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -24,7 +24,7 @@ main() Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { int weight = lexical_cast(edge_attr_map[*ei]["label"]); property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index 330f9081..d982c580 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index cb181969..96f5ef82 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -22,7 +22,7 @@ main() using NodeMap = property_map::type; auto node_name_map = get(vertex_all, g); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << node_name_map[*vi] << std::endl; return EXIT_SUCCESS; } diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 83e64523..39cd36b4 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -91,7 +91,7 @@ compute_loop_extent(typename graph_traits < get(vertex_index, g), c)); typename graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (reachable_from_head[*vi] != Color::white() && reachable_to_tail[*vi] != Color::white()) loop_set.insert(*vi); @@ -138,7 +138,7 @@ main(int argc, char *argv[]) vattr_map[*j]["color"] = "gray"; in_loop[*j] = true; } - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) if (in_loop[source(*ei, g)] && in_loop[target(*ei, g)]) eattr_map[*ei]["color"] = "gray"; } @@ -151,7 +151,7 @@ main(int argc, char *argv[]) << "ratio=\"fill\"\n" << "shape=\"box\"\n"; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; for (auto ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { @@ -162,7 +162,7 @@ main(int argc, char *argv[]) loops_out<< "]"; } - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; auto& attr_map = eattr_map[*ei]; for (auto eai = attr_map.begin(); diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index 34757850..80f681ae 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -47,7 +47,7 @@ int main(int argc, char** argv) auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); @@ -80,7 +80,7 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); // Re-size the storage for the biconnected components, since we diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index b0439568..e7484546 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -70,7 +70,7 @@ int main(int argc, char** argv) auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); @@ -90,7 +90,7 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); @@ -112,7 +112,7 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); // Test for planarity one final time; compute the planar embedding as a diff --git a/example/matching_example.cpp b/example/matching_example.cpp index c91901f5..0e909489 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -83,7 +83,7 @@ int main() std::cout << "The matching is:" << std::endl; graph_traits::vertex_iterator vi, vi_end; - for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (mate[*vi] != graph_traits::null_vertex() && *vi < mate[*vi]) std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl; @@ -109,7 +109,7 @@ int main() std::cout << "The matching is:" << std::endl; - for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (mate[*vi] != graph_traits::null_vertex() && *vi < mate[*vi]) std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl; diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 9c999c3e..1109dc60 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -82,8 +82,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits::vertex_iterator u_iter, u_end; graph_traits::out_edge_iterator ei, e_end; - for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index 606c325c..14dfb7ca 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -76,7 +76,7 @@ main(int argc, char *argv[]) // Print the mean geodesic distance of each vertex and finally, // the graph itself. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << get(gm, *i) << std::endl; } diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index 966c82cb..fb35efb4 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -61,7 +61,7 @@ main(int , char* []) auto weightmap = get(edge_weight, G); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; - boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); + std::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); weightmap[e] = weights[j]; } #else @@ -88,14 +88,14 @@ main(int , char* []) std::cout << "distances from start vertex:" << std::endl; graph_traits::vertex_iterator vi, vend; - for(boost::tie(vi,vend) = vertices(G); vi != vend; ++vi) + for(std::tie(vi,vend) = vertices(G); vi != vend; ++vi) std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << std::endl; std::cout << std::endl; std::cout << "min-max paths tree" << std::endl; adjacency_list<> tree(num_nodes); - for(boost::tie(vi,vend) = vertices(G); vi != vend; ++vi) + for(std::tie(vi,vend) = vertices(G); vi != vend; ++vi) if (*vi != p[*vi]) add_edge(p[*vi], *vi, tree); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 4868c611..a24b1a48 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -85,7 +85,7 @@ void modify_demo(MutableGraph& g) u = add_vertex(g); v = add_vertex(g); - boost::tie(e, added) = add_edge(u, v, g); + std::tie(e, added) = add_edge(u, v, g); assert(num_edges(g) == m + 2); assert(added == true); // edge should have been added @@ -101,14 +101,14 @@ void modify_demo(MutableGraph& g) assert(num_edges(g) == m + 1); bool exists; - boost::tie(e, exists) = edge(u, v, g); + std::tie(e, exists) = edge(u, v, g); assert(exists == false); assert(out_degree(u, g) == 0); assert(in_degree(v, g) == 0); } { e = *edges(g).first; - boost::tie(u, v) = incident(e, g); + std::tie(u, v) = incident(e, g); remove_edge(e, g); @@ -120,7 +120,7 @@ void modify_demo(MutableGraph& g) add_edge(u, v, g); typename GraphTraits::out_edge_iterator iter, iter_end; - boost::tie(iter, iter_end) = out_edges(u, g); + std::tie(iter, iter_end) = out_edges(u, g); remove_edge(iter, g); @@ -130,13 +130,13 @@ void modify_demo(MutableGraph& g) } { w = add_vertex(g); - boost::tie(e1, added) = add_edge(u, v, g); - boost::tie(e2, added) = add_edge(v, w, g); + std::tie(e1, added) = add_edge(u, v, g); + std::tie(e2, added) = add_edge(v, w, g); name_map[e1] = "I-5"; name_map[e2] = "Route 66"; typename GraphTraits::out_edge_iterator iter, iter_end; - boost::tie(iter, iter_end) = out_edges(u, g); + std::tie(iter, iter_end) = out_edges(u, g); remove_edge_if(name_equals("Route 66", name_map), g); @@ -151,8 +151,8 @@ void modify_demo(MutableGraph& g) assert(in_degree(w, g) == 0); } { - boost::tie(e1, added) = add_edge(u, v, g); - boost::tie(e2, added) = add_edge(u, w, g); + std::tie(e1, added) = add_edge(u, v, g); + std::tie(e2, added) = add_edge(u, w, g); name_map[e1] = "foo"; name_map[e2] = "foo"; @@ -162,8 +162,8 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); } { - boost::tie(e1, added) = add_edge(u, v, g); - boost::tie(e2, added) = add_edge(w, v, g); + std::tie(e1, added) = add_edge(u, v, g); + std::tie(e2, added) = add_edge(w, v, g); name_map[e1] = "bar"; name_map[e2] = "bar"; @@ -182,9 +182,9 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { typename GraphTraits::adjacency_iterator ai, ai_end; - for (boost::tie(ai, ai_end) = adjacent_vertices(*vi, g); + for (std::tie(ai, ai_end) = adjacent_vertices(*vi, g); ai != ai_end; ++ai) assert(*ai != u); } diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 9eadf8af..a5494c16 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -95,9 +95,9 @@ main() graph_traits::vertex_iterator i, end; graph_traits::out_edge_iterator ei, edge_end; - for (boost::tie(i, end) = vertices(g); i != end; ++i) { + for (std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << id[*i] << " "; - for (boost::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) + for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; std::cout << std::endl; } @@ -108,14 +108,14 @@ main() Traits::edge_descriptor e; Traits::out_edge_iterator e_first, e_last; - boost::tie(e, found) = edge(0, 1, g); + std::tie(e, found) = edge(0, 1, g); if (found) std::cout << "name(0,1) = " << name[e] << std::endl; else std::cout << "not found" << std::endl; std::cout << std::endl; - boost::tie(e_first, e_last) = edge_range(0, 1, g); + std::tie(e_first, e_last) = edge_range(0, 1, g); while (e_first != e_last) std::cout << "name(0,1) = " << name[*e_first++] << std::endl; #endif diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 412e0c7e..353b891e 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -42,7 +42,7 @@ main() using vertex_descriptor = graph_traits::vertex_descriptor; Graph g(num_vertices(g_dot)); graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { auto weight = get(edge_weight, g_dot, *ei); property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); @@ -50,7 +50,7 @@ main() vertex_descriptor router_six; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) if ("RT6" == get(vertex_name, g_dot, *vi)) { router_six = *vi; break; @@ -89,7 +89,7 @@ main() std::ofstream rtable("routing-table.dat"); rtable << "Dest Next Hop Total Cost" << std::endl; - for (boost::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) if (parent[*vi] != *vi) { rtable << get(vertex_name, g_dot, *vi) << " "; vertex_descriptor v = *vi, child; diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index b7fbfb08..f4813cc9 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -58,7 +58,7 @@ dfs_v2(const Graph & g, color[u] = ColorT::gray(); vis.discover_vertex(u, g); typename graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) if (color[target(*ei, g)] == ColorT::white()) { vis.tree_edge(*ei, g); dfs_v2(g, target(*ei, g), color, vis); @@ -76,9 +76,9 @@ generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) using ColorValue = typename property_traits ::value_type; using ColorT = color_traits ; typename graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) color[*vi] = ColorT::white(); - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (color[*vi] == ColorT::white()) dfs_v2(g, *vi, color, vis); } @@ -132,7 +132,7 @@ main() id2vertex.emplace_back(add_vertex(g)); while (input_begin != input_end) { size_type i, j; - boost::tie(i, j) = *input_begin++; + std::tie(i, j) = *input_begin++; add_edge(id2vertex[i], id2vertex[j], g); } #else @@ -156,7 +156,7 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; } @@ -169,14 +169,14 @@ main() graph_traits::adjacency_iterator vi, vi_end; // find source vertices with zero in-degree by marking all vertices with incoming edges - for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) + for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) color_map[*i] = white_color; - for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) - for (boost::tie(vi, vi_end) = adjacent_vertices(*i, g); vi != vi_end; ++vi) + for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) + for (std::tie(vi, vi_end) = adjacent_vertices(*i, g); vi != vi_end; ++vi) color_map[*vi] = black_color; // initialize distances to zero, or for source vertices, to the compile cost - for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) + for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) if (color_map[*i] == white_color) distance_map[*i] = compile_cost_map[*i]; else @@ -187,14 +187,14 @@ main() vertex_t u = * ui; - for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (distance_map[*vi] < distance_map[u] + compile_cost_map[*vi]) distance_map[*vi] = distance_map[u] + compile_cost_map[*vi]; } graph_property_iter_range < file_dep_graph2, vertex_distance_t >::iterator ci, ci_end; - boost::tie(ci, ci_end) = get_property_iter_range(g, vertex_distance); + std::tie(ci, ci_end) = get_property_iter_range(g, vertex_distance); std::cout << "total (parallel) compile time: " << *std::max_element(ci, ci_end) << std::endl; diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index 27ad8715..57d91820 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -93,7 +93,7 @@ int main(int argc, char** argv) auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; graph_traits::edge_iterator ei, ei_end; - for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(e_index, *ei, edge_count++); diff --git a/example/prim-example.cpp b/example/prim-example.cpp index 2a2cc87a..006e63e8 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -27,7 +27,7 @@ main() auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; - boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); + std::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); weightmap[e] = weights[j]; } #else diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 5fe612b9..b6079dc4 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -24,7 +24,7 @@ main() Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { auto weight = lexical_cast(edge_attr_map[*ei]["label"]); property edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 2912042b..ce0df7b6 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -43,7 +43,7 @@ output_adjacent_vertices(std::ostream & out, { typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } @@ -101,7 +101,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits::vertex_iterator i, end; - boost::tie(i, end) = vertices(g); + std::tie(i, end) = vertices(g); i = std::find_if(i, end, name_equals("dax.h", get(vertex_name, g))); output_adjacent_vertices(std::cout, *i, g, get(vertex_name, g)); diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 2074c4a8..b4616d3c 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -41,7 +41,7 @@ print_dependencies(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -$>$ " << get(name_map, target(*ei, g)) << std::endl; } diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index c3e38d27..fcf84eb1 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -42,7 +42,7 @@ output_in_edges(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits::in_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } @@ -101,7 +101,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits::vertex_iterator i, end; - boost::tie(i, end) = vertices(g); + std::tie(i, end) = vertices(g); i = std::find_if(i, end, name_equals("libzigzag.a", get(vertex_name, g))); output_in_edges(std::cout, g, *i, get(vertex_name, g)); assert(num_vertices(g) == 15); diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index 6c331910..beefc4a5 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -42,7 +42,7 @@ output_out_edges(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } @@ -100,7 +100,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits::vertex_iterator i, end; - boost::tie(i, end) = vertices(g); + std::tie(i, end) = vertices(g); using name_map_t = property_map::type; name_equals_t predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index e52362e3..37310bb2 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -73,8 +73,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits::vertex_iterator u_iter, u_end; graph_traits::out_edge_iterator ei, e_end; - for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 83e04a5f..19c41c86 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -46,7 +46,7 @@ print_trans_delays(const Graph & g, TransDelayMap trans_delay_map, VertexNameMap name_map) { typename graph_traits::edge_iterator first, last; - for (boost::tie(first, last) = edges(g); first != last; ++first) { + for (std::tie(first, last) = edges(g); first != last; ++first) { print_trans_delay(*first, g, trans_delay_map, name_map); std::cout << std::endl; } @@ -71,19 +71,19 @@ build_router_network(Graph & g, VertexNameMap name_map, typename graph_traits::edge_descriptor ed; bool inserted; - boost::tie(ed, inserted) = add_edge(a, b, g); + std::tie(ed, inserted) = add_edge(a, b, g); delay_map[ed] = 1.2; - boost::tie(ed, inserted) = add_edge(a, d, g); + std::tie(ed, inserted) = add_edge(a, d, g); delay_map[ed] = 4.5; - boost::tie(ed, inserted) = add_edge(b, d, g); + std::tie(ed, inserted) = add_edge(b, d, g); delay_map[ed] = 1.8; - boost::tie(ed, inserted) = add_edge(c, a, g); + std::tie(ed, inserted) = add_edge(c, a, g); delay_map[ed] = 2.6; - boost::tie(ed, inserted) = add_edge(c, e, g); + std::tie(ed, inserted) = add_edge(c, e, g); delay_map[ed] = 5.2; - boost::tie(ed, inserted) = add_edge(d, c, g); + std::tie(ed, inserted) = add_edge(d, c, g); delay_map[ed] = 0.4; - boost::tie(ed, inserted) = add_edge(d, e, g); + std::tie(ed, inserted) = add_edge(d, e, g); delay_map[ed] = 3.3; } diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 94fcb0e8..5a8f6f79 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -11,7 +11,7 @@ #include // for std::cout #include // for std::pair #include // for std::for_each -#include // for boost::tie +#include // for std::tie #include #include @@ -30,7 +30,7 @@ template struct exercise_vertex { std::cout << "\tout-edges: "; typename graph_traits::out_edge_iterator out_i, out_end; typename graph_traits::edge_descriptor e; - for (boost::tie(out_i, out_end) = out_edges(v, g); + for (std::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; @@ -43,7 +43,7 @@ template struct exercise_vertex { // Write out the incoming edges std::cout << "\tin-edges: "; typename graph_traits::in_edge_iterator in_i, in_end; - for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) + for (std::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { e = *in_i; Vertex src = source(e, g), targ = target(e, g); @@ -55,7 +55,7 @@ template struct exercise_vertex { // Write out all adjacent vertices std::cout << "\tadjacent vertices: "; typename graph_traits::adjacency_iterator ai, ai_end; - for (boost::tie(ai,ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) + for (std::tie(ai,ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) std::cout << name[get(vertex_id, *ai)] << " "; std::cout << std::endl; } @@ -92,7 +92,7 @@ int main(int,char*[]) auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { graph_traits::edge_descriptor e; bool inserted; - boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + std::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = transmission_delay[j]; } #else @@ -114,7 +114,7 @@ int main(int,char*[]) std::cout << "edges(g) = "; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) std::cout << "(" << name[get(vertex_id, source(*ei, g))] << "," << name[get(vertex_id, target(*ei, g))] << ") "; std::cout << std::endl; diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 53e83b77..35d0c689 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -37,7 +37,7 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); graph_traits::vertex_iterator i, i_end; - for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) + for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) if (reachable_from_head[*i] != Color::white()) { vattr_map[*i]["color"] = "gray"; vattr_map[*i]["style"] = "filled"; @@ -51,7 +51,7 @@ main(int argc, char *argv[]) << "ratio=\"fill\"\n" << "shape=\"box\"\n"; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; for (auto ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { @@ -64,7 +64,7 @@ main(int argc, char *argv[]) property_map::type eattr_map = get(edge_attribute, g); graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; std::map& attr_map = eattr_map[*ei]; for (auto eai = attr_map.begin(); diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index 9fae501b..3948b0e1 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -49,7 +49,7 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); graph_traits::vertex_iterator i, i_end; - for (boost::tie(i, i_end) = vertices(g_in); i != i_end; ++i) { + for (std::tie(i, i_end) = vertices(g_in); i != i_end; ++i) { loops_out << *i << "[label=\"" << vattr_map[*i]["label"] << "\""; if (reachable_to_tail[*i] != Color::white()) { @@ -58,7 +58,7 @@ main(int argc, char *argv[]) loops_out << "]\n"; } graph_traits::edge_iterator e, e_end; - for (boost::tie(e, e_end) = edges(g_in); e != e_end; ++e) + for (std::tie(e, e_end) = edges(g_in); e != e_end; ++e) loops_out << source(*e, g) << " -> " << target(*e, g) << ";\n"; loops_out << "}\n"; return EXIT_SUCCESS; diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index e11b0f5e..783dbb35 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -88,12 +88,12 @@ int main() //we take the source node and check for each outgoing edge e which has a target(p) if we can augment that path out_edge_iterator oei,oe_end; - for(boost::tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ + for(std::tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ auto from_source = *oei; auto v = target(from_source, g); edge_descriptor to_sink; bool is_there; - boost::tie(to_sink, is_there) = edge(v, t, g); + std::tie(to_sink, is_there) = edge(v, t, g); if( is_there ){ if( get(capacity, to_sink) > get(capacity, from_source) ){ auto to_augment = get(capacity, from_source); diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 668bc9b6..7c00c38d 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -79,7 +79,7 @@ main() int w = 0; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; auto indexmap = get(vertex_index, g); diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 5df1dc7f..50e0d9a8 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -78,7 +78,7 @@ main() int w = 0; graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; std::cout << "original graph:" << std::endl; diff --git a/example/roget_components.cpp b/example/roget_components.cpp index 1e7495ce..01567c69 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -70,12 +70,12 @@ int main(int argc, char* argv[]) // First add representative vertices to each component's list graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] == *vi) strong_comp[comp[index_map[*vi]]].emplace_back(*vi); // Then add the other vertices of the component - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] != *vi) strong_comp[comp[index_map[*vi]]].emplace_back(*vi); @@ -115,7 +115,7 @@ int main(int argc, char* argv[]) for (i = 0; i < strong_comp[c].size(); ++i) { vertex_t v = strong_comp[c][i]; graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { auto x = target(*ei, g); auto comp_x = comp[index_map[x]]; if (comp_x != c && mark[comp_x] != c) { diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index 3da40098..af1d27cf 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -103,7 +103,7 @@ main(int argc, char *argv[]) // Print the scaled closeness centrality of each vertex. graph_traits::vertex_iterator i, end; - for(boost::tie(i, end) = vertices(g); i != end; ++i) { + for(std::tie(i, end) = vertices(g); i != end; ++i) { std::cout << std::setw(12) << std::setiosflags(std::ios::left) << g[*i].name << get(cm, *i) << std::endl; } diff --git a/example/scc.cpp b/example/scc.cpp index 87f6fbd8..f909b6f3 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -28,7 +28,7 @@ main() std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; if (vertex_attr_map[*vi]["color"] == "black") diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index 3eabb4f8..d18f608b 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -113,7 +113,7 @@ int main(int , char* []) //Creating a property_map with the degrees of the degrees of each vertex auto deg = get(vertex_degree, G); - for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) deg[*ui] = degree(*ui, G); //Creating a property_map for the indices of a vertex diff --git a/example/straight_line_drawing.cpp b/example/straight_line_drawing.cpp index 87e2a11f..0e38cd44 100644 --- a/example/straight_line_drawing.cpp +++ b/example/straight_line_drawing.cpp @@ -114,7 +114,7 @@ int main(int argc, char** argv) std::cout << "The straight line drawing is: " << std::endl; graph_traits::vertex_iterator vi, vi_end; - for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { coord_t coord(get(straight_line_drawing,*vi)); std::cout << *vi << " -> (" << coord.x << ", " << coord.y << ")" diff --git a/example/subgraph.cpp b/example/subgraph.cpp index d720c569..a8764dd1 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -76,7 +76,7 @@ int main(int,char*[]) Graph::children_iterator ci, ci_end; int num = 1; - for (boost::tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) { + for (std::tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) { std::cout << "G" << num++ << ":" << std::endl; print_graph(*ci, get(vertex_index, *ci)); print_edges2(*ci, get(vertex_index, *ci), get(edge_index, *ci)); diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index 32e30313..ff52b0c3 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -28,7 +28,7 @@ main(int argc, char *argv[]) // Compute the girth and circumference simulataneously size_t girth, circ; - boost::tie(girth, circ) = tiernan_girth_and_circumference(g); + std::tie(girth, circ) = tiernan_girth_and_circumference(g); // Print the result std::cout << "girth: " << girth << std::endl; diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 8e9690c1..46860a38 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -38,7 +38,7 @@ topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, { mark[u] = 1; // 1 means visited, 0 means not yet visited graph_traits::adjacency_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, mark); @@ -50,7 +50,7 @@ topo_sort(const file_dep_graph & g, vertex_t * topo_order) { std::vectormark(num_vertices(g), 0); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, &mark[0]); } @@ -70,7 +70,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - boost::tie(i, j) = *input_begin++; + std::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -80,7 +80,7 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; std::vector order(num_vertices(g)); diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index a414c992..63188355 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -42,7 +42,7 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, color[u] = gray_color; vis.discover_vertex(u, g); graph_traits::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); dfs_v1(g, target(*ei, g), color, vis); @@ -60,7 +60,7 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector color(num_vertices(g), white_color); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); } @@ -130,7 +130,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - boost::tie(i, j) = *input_begin++; + std::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -140,7 +140,7 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits::vertex_iterator vi, vi_end; - for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; std::vector order(num_vertices(g)); diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 99725425..6cc85c4a 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -23,7 +23,7 @@ main() auto name_map = get(vertex_name, G); char name = 'a'; graph_traits::vertex_iterator v, v_end; - for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; using E = std::pair; @@ -42,7 +42,7 @@ main() print_graph(G_T, name_map); graph_traits::edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) + for (std::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) assert(edge(target(*ei, G), source(*ei, G), G_T).second == true); return 0; } diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 0489d7fa..3ca41d91 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -26,10 +26,10 @@ undirected_graph_demo1() add_edge(one, two, undigraph); std::cout << "out_edges(0):"; - for (boost::tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out) + for (std::tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out) std::cout << ' ' << *out; std::cout << std::endl << "in_edges(0):"; - for (boost::tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in) + for (std::tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in) std::cout << ' ' << *in; std::cout << std::endl; } @@ -48,8 +48,8 @@ directed_graph_demo() auto v = vertex(1, digraph); add_edge(u, v, Weight(1.2), digraph); add_edge(v, u, Weight(2.4), digraph); - boost::tie(e1, found) = edge(u, v, digraph); - boost::tie(e2, found) = edge(v, u, digraph); + std::tie(e1, found) = edge(u, v, digraph); + std::tie(e2, found) = edge(v, u, digraph); std::cout << "in a directed graph is "; #ifdef __GNUC__ // no boolalpha @@ -76,8 +76,8 @@ undirected_graph_demo2() auto u = vertex(0, undigraph); auto v = vertex(1, undigraph); add_edge(u, v, Weight(3.1), undigraph); - boost::tie(e1, found) = edge(u, v, undigraph); - boost::tie(e2, found) = edge(v, u, undigraph); + std::tie(e1, found) = edge(u, v, undigraph); + std::tie(e2, found) = edge(v, u, undigraph); std::cout << "in an undirected graph is "; #ifdef __GNUC__ std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl; @@ -91,7 +91,7 @@ undirected_graph_demo2() std::cout << "the edges incident to v: "; typename boost::graph_traits::out_edge_iterator e, e_end; auto s = vertex(0, undigraph); - for (boost::tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e) + for (std::tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e) std::cout << "(" << source(*e, undigraph) << "," << target(*e, undigraph) << ")" << std::endl; } From 72485a31ac07e3fbc7a91e4e080c9843f7cbc629 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 10 May 2017 12:03:59 +0200 Subject: [PATCH 15/28] examples: C++11: More use of auto. --- example/kuratowski_subgraph.cpp | 5 ++--- example/quick_tour.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index d982c580..66ec5638 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -70,9 +70,8 @@ int main(int argc, char** argv) std::cout << "Input graph is not planar" << std::endl; std::cout << "Edges in the Kuratowski subgraph: "; - kuratowski_edges_t::iterator ki, ki_end; - ki_end = kuratowski_edges.end(); - for(ki = kuratowski_edges.begin(); ki != ki_end; ++ki) + auto ki_end = kuratowski_edges.end(); + for(auto ki = kuratowski_edges.begin(); ki != ki_end; ++ki) { std::cout << *ki << " "; } diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 5a8f6f79..1ff3a3ac 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -29,11 +29,10 @@ template struct exercise_vertex { // Write out the outgoing edges std::cout << "\tout-edges: "; typename graph_traits::out_edge_iterator out_i, out_end; - typename graph_traits::edge_descriptor e; for (std::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { - e = *out_i; + auto e = *out_i; auto src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; @@ -45,7 +44,7 @@ template struct exercise_vertex { typename graph_traits::in_edge_iterator in_i, in_end; for (std::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { - e = *in_i; + auto e = *in_i; Vertex src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; From b6bb7661b3e3f5c63993446f1930f87bd05e8cbb Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 2 Nov 2016 12:01:10 +0100 Subject: [PATCH 16/28] examples: C++11: Add and use make_range_pair(). This could be improved with "structured bindings" if that gets into C++17, but that alone would still not allow a range-based for loop. http://eli.thegreenplace.net/2016/returning-multiple-values-from-functions-in-c#structured-bindings-a-new-hope-for-c-17 --- example/accum-compile-times.cpp | 8 ++-- example/actor_clustering.cpp | 11 +++--- example/adjacency_list.cpp | 28 +++++++------- example/bellman-example.cpp | 11 +++--- example/bfs-example2.cpp | 8 ++-- example/biconnected_components.cpp | 10 ++--- example/bipartite_example.cpp | 6 +-- example/boost_web_graph.cpp | 14 +++---- example/boykov_kolmogorov-eg.cpp | 13 +++---- example/canonical_ordering.cpp | 6 +-- example/cc-internet.cpp | 12 +++--- example/closeness_centrality.cpp | 8 ++-- example/clustering_coefficient.cpp | 8 ++-- example/copy-example.cpp | 8 ++-- example/cuthill_mckee_ordering.cpp | 7 ++-- example/cycle-file-dep.cpp | 22 +++++------ example/cycle-file-dep2.cpp | 28 +++++++------- example/cycle_ratio_example.cpp | 6 +-- example/dag_shortest_paths.cpp | 10 ++--- example/dave.cpp | 12 +++--- example/degree_centrality.cpp | 8 ++-- example/dfs-parenthesis.cpp | 8 ++-- example/dijkstra-example-listS.cpp | 19 +++++----- example/dijkstra-example.cpp | 12 +++--- example/dijkstra-no-color-map-example.cpp | 12 +++--- example/eccentricity.cpp | 8 ++-- example/edge-connectivity.cpp | 40 +++++++++----------- example/edge-function.cpp | 6 +-- example/edge_property.cpp | 37 +++++++------------ example/edmonds-karp-eg.cpp | 13 +++---- example/exterior_properties.cpp | 26 +++++-------- example/family_tree.cpp | 9 +++-- example/file_dependencies.cpp | 11 +++--- example/filtered-copy-example.cpp | 8 ++-- example/filtered_graph_edge_range.cpp | 15 ++++---- example/fr_layout.cpp | 8 ++-- example/gerdemann.cpp | 29 ++++++--------- example/girth.cpp | 6 +-- example/graph-property-iter-eg.cpp | 9 +++-- example/graph.cpp | 12 +++--- example/implicit_graph.cpp | 28 ++++++-------- example/in_edges.cpp | 13 +++---- example/inclusive_mean_geodesic.cpp | 12 +++--- example/influence_prestige.cpp | 7 ++-- example/isomorphism.cpp | 16 ++++---- example/johnson-eg.cpp | 13 +++---- example/kevin-bacon.cpp | 8 ++-- example/kevin-bacon2.cpp | 14 +++---- example/king_ordering.cpp | 7 ++-- example/knights_tour.cpp | 22 +++++------ example/kruskal-example.cpp | 12 +++--- example/kruskal-telephone.cpp | 8 ++-- example/kuratowski_subgraph.cpp | 6 +-- example/last-mod-time.cpp | 13 +++---- example/leda-graph-eg.cpp | 5 +-- example/loops_dfs.cpp | 34 ++++++++--------- example/make_biconnected_planar.cpp | 10 ++--- example/make_maximal_planar.cpp | 14 +++---- example/matching_example.cpp | 16 ++++---- example/max_flow.cpp | 13 +++---- example/mean_geodesic.cpp | 8 ++-- example/min_max_paths.cpp | 10 ++--- example/modify_graph.cpp | 10 ++--- example/ordered_out_edges.cpp | 11 +++--- example/ospf-example.cpp | 23 ++++++------ example/parallel-compile-time.cpp | 61 ++++++++++++++----------------- example/planar_face_traversal.cpp | 6 +-- example/prim-telephone.cpp | 9 +++-- example/print-adjacent-vertices.cpp | 6 +-- example/print-edges.cpp | 8 ++-- example/print-in-edges.cpp | 8 ++-- example/print-out-edges.cpp | 8 ++-- example/push-relabel-eg.cpp | 17 ++++----- example/quick-tour.cpp | 5 +-- example/quick_tour.cpp | 26 +++++-------- example/range_pair.hpp | 48 ++++++++++++++++++++++++ example/reachable-loop-head.cpp | 28 +++++++------- example/reachable-loop-tail.cpp | 13 +++---- example/read_write_dimacs-eg.cpp | 9 ++--- example/remove_edge_if_bidir.cpp | 6 +-- example/remove_edge_if_undir.cpp | 6 +-- example/roget_components.cpp | 19 +++++----- example/scaled_closeness_centrality.cpp | 8 ++-- example/scc.cpp | 11 +++--- example/sloan_ordering.cpp | 8 ++-- example/straight_line_drawing.cpp | 7 ++-- example/subgraph.cpp | 8 ++-- example/topo-sort-file-dep.cpp | 20 +++++----- example/topo-sort-file-dep2.cpp | 28 +++++++------- example/transpose-example.cpp | 11 +++--- example/undirected_adjacency_list.cpp | 19 +++++----- example/vertex_basics.cpp | 5 ++- 92 files changed, 619 insertions(+), 654 deletions(-) create mode 100644 example/range_pair.hpp diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 853bc2e3..34376263 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "range_pair.hpp" namespace std { @@ -73,10 +74,9 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - name_in >> name_map[*vi]; - compile_cost_in >> compile_cost_map[*vi]; + for(const auto& vertex : make_range_pair(vertices(g))) { + name_in >> name_map[vertex]; + compile_cost_in >> compile_cost_map[vertex]; } graph_property_iter_range < file_dep_graph2, diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 92923bba..54a7f424 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -78,14 +79,14 @@ write_pajek_graph(std::ostream& out, const Graph& g, VertexIndexMap vertex_index, VertexNameMap vertex_name) { out << "*Vertices " << num_vertices(g) << '\n'; - for (auto v = vertices(g).first; v != vertices(g).second; ++v) { - out << get(vertex_index, *v)+1 << " \"" << get(vertex_name, *v) << "\"\n"; + for (const auto& vertex : make_range_pair(vertices(g))) { + out << get(vertex_index, vertex)+1 << " \"" << get(vertex_name, vertex) << "\"\n"; } out << "*Edges\n"; - for (auto e = edges(g).first; e != edges(g).second; ++e) { - out << get(vertex_index, source(*e, g))+1 << ' ' - << get(vertex_index, target(*e, g))+1 << " 1.0\n"; // HACK! + for (const auto& edge : make_range_pair(edges(g))) { + out << get(vertex_index, source(edge, g))+1 << ' ' + << get(vertex_index, target(edge, g))+1 << " 1.0\n"; // HACK! } return out; } diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index cd1969cc..2d9a3495 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "range_pair.hpp" /* Sample Output @@ -61,11 +62,9 @@ int main(int , char* []) auto id = get(&VertexProperties::index, g); auto name = get(&EdgeProperties::name, g); - boost::graph_traits::vertex_iterator vi, viend; int vnum = 0; - - for (std::tie(vi,viend) = vertices(g); vi != viend; ++vi) - id[*vi] = vnum++; + for(const auto& vertex : make_range_pair(vertices(g))) + id[vertex] = vnum++; add_edge(vertex(0, g), vertex(1, g), EdgeProperties("joe"), g); add_edge(vertex(1, g), vertex(2, g), EdgeProperties("curly"), g); @@ -73,27 +72,26 @@ int main(int , char* []) add_edge(vertex(2, g), vertex(4, g), EdgeProperties("tom"), g); add_edge(vertex(3, g), vertex(4, g), EdgeProperties("harry"), g); - graph_traits::vertex_iterator i, end; - graph_traits::out_edge_iterator ei, edge_end; - for (std::tie(i,end) = vertices(g); i != end; ++i) { - std::cout << id[*i] << " "; - for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << id[vertex] << " "; + for (const auto out_edge : make_range_pair(out_edges(vertex, g))) + std::cout << " --" << name[out_edge] << "--> " << id[target(out_edge, g)] << " "; + std::cout << std::endl; } print_edges(g, id); std::cout << std::endl << "removing edge (1,3): " << std::endl; remove_edge(vertex(1, g), vertex(3, g), g); - ei = out_edges(vertex(1, g), g).first; + auto ei = out_edges(vertex(1, g), g).first; std::cout << "removing edge (" << id[source(*ei, g)] << "," << id[target(*ei, g)] << ")" << std::endl; remove_edge(ei, g); - for(std::tie(i,end) = vertices(g); i != end; ++i) { - std::cout << id[*i] << " "; - for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << id[vertex] << " "; + for (const auto out_edge : make_range_pair(out_edges(vertex, g))) + std::cout << " --" << name[out_edge] << "--> " << id[target(out_edge, g)] << " "; std::cout << std::endl; } diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index cea3639f..a0f8f3dc 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -69,11 +70,12 @@ main() #else Graph g(edge_array, edge_array + n_edges, N); #endif - graph_traits::edge_iterator ei, ei_end; auto weight_pmap = get(&EdgeProperties::weight, g); int i = 0; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) - weight_pmap[*ei] = weight[i]; + for (const auto& edge : make_range_pair(edges(g))) { + weight_pmap[edge] = weight[i]; + ++i; + } std::vector distance(N, (std::numeric_limits::max)()); std::vector parent(N); @@ -106,8 +108,7 @@ main() << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; { - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - auto e = *ei; + for(const auto& e : make_range_pair(edges(g))) { auto u = source(e, g), v = target(e, g); // VC++ doesn't like the 3-argument get function, so here // we workaround by using 2-nested get()'s. diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index 5e13b442..74038f3b 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" #include @@ -79,11 +80,10 @@ main() using dtime_pm_type = iterator_property_map::iterator, property_map::type>; - graph_traits::vertex_iterator vi, vi_end; std::size_t c = 0; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) { - dtime[c] = dtime_map[*vi]; - put(&VertexProps::index, g, *vi, c); + for (const auto& vertex : make_range_pair(vertices(g))) { + dtime[c] = dtime_map[vertex]; + put(&VertexProps::index, g, vertex, c); } dtime_pm_type dtime_pm(dtime.begin(), get(&VertexProps::index, g)); diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 0234740c..6588ae31 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" namespace boost { @@ -61,11 +62,10 @@ main() << std::endl; } - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - std::cout << (char)(source(*ei, g) + 'A') << " -- " - << (char)(target(*ei, g) + 'A') - << "[label=\"" << component[*ei] << "\"]\n"; + for(const auto& edge : make_range_pair(edges(g))) + std::cout << (char)(source(edge, g) + 'A') << " -- " + << (char)(target(edge, g) + 'A') + << "[label=\"" << component[edge] << "\"]\n"; std::cout << "}\n"; return 0; diff --git a/example/bipartite_example.cpp b/example/bipartite_example.cpp index 26c49838..62ae8af8 100644 --- a/example/bipartite_example.cpp +++ b/example/bipartite_example.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -22,7 +23,6 @@ template void print_bipartite (const Graph& g) { using traits = graph_traits ; - typename traits::vertex_iterator vertex_iter, vertex_end; /// Most simple interface just tests for bipartiteness. @@ -41,9 +41,9 @@ void print_bipartite (const Graph& g) is_bipartite (g, get (vertex_index, g), partition_map); - for (std::tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter) + for (const auto& vertex : make_range_pair(vertices (g))) { - std::cout << "Vertex " << *vertex_iter << " has color " << (get (partition_map, *vertex_iter) == color_traits < + std::cout << "Vertex " << vertex << " has color " << (get (partition_map, vertex) == color_traits < default_color_type>::white () ? "white" : "black") << std::endl; } } diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index e59cba31..fde152c7 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "range_pair.hpp" template @@ -167,9 +168,8 @@ main() << std::endl << std::endl; std::cout << "Number of clicks from the home page: " << std::endl; - Traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - std::cout << d_matrix[0][*vi] << "\t" << node_name[*vi] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << d_matrix[0][vertex] << "\t" << node_name[vertex] << std::endl; std::cout << std::endl; //=========================================================================== @@ -177,8 +177,8 @@ main() // Create storage for a mapping from vertices to their parents std::vector parent(num_vertices(g)); - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - parent[*vi] = *vi; + for (const auto& vertex : make_range_pair(vertices(g))) + parent[vertex] = vertex; // Do a BFS starting at the home page, recording the parent of each // vertex (where parent is with respect to the search tree). @@ -205,8 +205,8 @@ main() using NameMap = property_map::type; print_tree_visitor tree_printer(node_name, &dfs_distances[0]); - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - get(vertex_color, g)[*vi] = white_color; + for(const auto& vertex : make_range_pair(vertices(g))) + get(vertex_color, g)[vertex] = white_color; depth_first_visit(search_tree, src, tree_printer, get(vertex_color, g)); return EXIT_SUCCESS; diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index 31cc70de..d4fab036 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -36,6 +36,7 @@ #include #include #include +#include "range_pair.hpp" // Use a DIMACS network flow file as stdin. // boykov_kolmogorov-eg < max_flow.dat @@ -97,13 +98,11 @@ int main() std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) - std::cout << "f " << *u_iter << " " << target(*ei, g) << " " - << (capacity[*ei] - residual_capacity[*ei]) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + if (capacity[edge] > 0) + std::cout << "f " << vertex << " " << target(edge, g) << " " + << (capacity[edge] - residual_capacity[edge]) << std::endl; return EXIT_SUCCESS; } diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index f959d384..4821602f 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -15,6 +15,7 @@ #include #include +#include "range_pair.hpp" using namespace boost; @@ -49,9 +50,8 @@ int main(int argc, char** argv) // Initialize the interior edge index auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; - graph_traits::edge_iterator ei, ei_end; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); // Test for planarity - we know it is planar, we just want to diff --git a/example/cc-internet.cpp b/example/cc-internet.cpp index b5764d37..26ed1691 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -28,12 +29,11 @@ main() auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - vertex_attr_map[*vi]["color"] = color[component[*vi]]; - vertex_attr_map[*vi]["style"] = "filled"; - if (vertex_attr_map[*vi]["color"] == "black") - vertex_attr_map[*vi]["fontcolor"] = "white"; + for(const auto& vertex : make_range_pair(vertices(g))) { + vertex_attr_map[vertex]["color"] = color[component[vertex]]; + vertex_attr_map[vertex]["style"] = "filled"; + if (vertex_attr_map[vertex]["color"] == "black") + vertex_attr_map[vertex]["fontcolor"] = "white"; } write_graphviz("figs/cc-internet-out.dot", g); diff --git a/example/closeness_centrality.cpp b/example/closeness_centrality.cpp index 8e842425..1a384be2 100644 --- a/example/closeness_centrality.cpp +++ b/example/closeness_centrality.cpp @@ -14,6 +14,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -73,10 +74,9 @@ main(int argc, char *argv[]) all_closeness_centralities(g, dm, cm); // Print the closeness centrality of each vertex. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name << get(cm, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name << get(cm, vertex) << std::endl; } return 0; diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index 97904480..84866d4d 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -13,6 +13,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -56,10 +57,9 @@ main(int argc, char *argv[]) auto cc = all_clustering_coefficients(g, cm); // Print the clustering coefficient of each vertex. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name << get(cm, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name << get(cm, vertex) << std::endl; } std::cout << "mean clustering coefficient: " << cc << std::endl; diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 9f87c73a..882031da 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -23,9 +24,10 @@ main() graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits::vertex_iterator v, v_end; - for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) - name_map[*v] = name; + for (const auto& vertex : make_range_pair(vertices(G))) { + name_map[vertex] = name; + ++name; + } using E = std::pair; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 9d436bea..1cd65d48 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "range_pair.hpp" /* Sample Output @@ -58,11 +59,9 @@ int main(int , char* []) for (const auto& edge : edges) add_edge(edge.first, edge.second, G); - graph_traits::vertex_iterator ui, ui_end; - auto deg = get(vertex_degree, G); - for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) - deg[*ui] = degree(*ui, G); + for(const auto& v : make_range_pair(vertices(G))) + deg[v] = degree(v, G); auto index_map = get(vertex_index, G); diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index 1c55e12a..9d13e74e 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -37,12 +38,11 @@ has_cycle_dfs(const file_dep_graph & g, vertex_t u, default_color_type * color) { color[u] = gray_color; - graph_traits::adjacency_iterator vi, vi_end; - for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) - if (color[*vi] == white_color) { - if (has_cycle_dfs(g, *vi, color)) + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + if (color[vertex] == white_color) { + if (has_cycle_dfs(g, vertex, color)) return true; // cycle detected, return immediately - } else if (color[*vi] == gray_color) // *vi is an ancestor! + } else if (color[vertex] == gray_color) // vertex is an ancestor! return true; color[u] = black_color; return false; @@ -52,10 +52,9 @@ bool has_cycle(const file_dep_graph & g) { std::vector color(num_vertices(g), white_color); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (color[*vi] == white_color) - if (has_cycle_dfs(g, *vi, &color[0])) + for (const auto& vertex : make_range_pair(vertices(g))) + if (color[vertex] == white_color) + if (has_cycle_dfs(g, vertex, &color[0])) return true; return false; } @@ -83,9 +82,8 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - name_in >> name[*vi]; + for (const auto& vertex : make_range_pair(vertices(g))) + name_in >> name[vertex]; assert(has_cycle(g) == false); return 0; diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index 44535745..cde0c3f4 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" // can't do using namespace boost because then // we get conflict with boost::default_dfs_visitor. @@ -41,15 +42,14 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, { color[u] = gray_color; vis.discover_vertex(u, g); - graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { - if (color[target(*ei, g)] == white_color) { - vis.tree_edge(*ei, g); - dfs_v1(g, target(*ei, g), color, vis); - } else if (color[target(*ei, g)] == gray_color) - vis.back_edge(*ei, g); + for (const auto& edge : make_range_pair(out_edges(u, g))) { + if (color[target(edge, g)] == white_color) { + vis.tree_edge(edge, g); + dfs_v1(g, target(edge, g), color, vis); + } else if (color[target(edge, g)] == gray_color) + vis.back_edge(edge, g); else - vis.forward_or_cross_edge(*ei, g); + vis.forward_or_cross_edge(edge, g); } color[u] = black_color; vis.finish_vertex(u, g); @@ -59,10 +59,9 @@ template void generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector color(num_vertices(g), white_color); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - if (color[*vi] == white_color) - dfs_v1(g, *vi, &color[0], vis); + for(const auto& vertex : make_range_pair(vertices(g))) { + if (color[vertex] == white_color) + dfs_v1(g, vertex, &color[0], vis); } } @@ -140,9 +139,8 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - name_in >> name[*vi]; + for (const auto& vertex : make_range_pair(vertices(g))) + name_in >> name[vertex]; assert(has_cycle(g) == false); return 0; diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 6a2d63a1..54fc8848 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" /** * @author Dmitry Bufistov @@ -57,9 +58,8 @@ int main(int argc, char* argv[]) std::cout << "Vertices number: " << num_vertices(tgr) << std::endl; std::cout << "Edges number: " << num_edges(tgr) << std::endl; int i = 0; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { - vim[*vi] = i++; ///Initialize vertex index property + for(const auto& vertex : make_range_pair(vertices(tgr))) { + vim[vertex] = i++; ///Initialize vertex index property } max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); std::cout << "Maximum cycle ratio is " << max_cr << std::endl; diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index f0878767..2194ea0c 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -9,6 +9,7 @@ #include #include +#include "range_pair.hpp" #include @@ -58,11 +59,10 @@ int main() dag_shortest_paths(g, s, distance_map(d_map)); #endif - graph_traits::vertex_iterator vi , vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (d_map[*vi] == (std::numeric_limits::max)()) - std::cout << name[*vi] << ": inifinity\n"; + for(const auto& vertex : make_range_pair(vertices(g))) + if (d_map[vertex] == (std::numeric_limits::max)()) + std::cout << name[vertex] << ": inifinity\n"; else - std::cout << name[*vi] << ": " << d_map[*vi] << '\n'; + std::cout << name[vertex] << ": " << d_map[vertex] << '\n'; return 0; } diff --git a/example/dave.cpp b/example/dave.cpp index 6d824cfc..595536fa 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -20,6 +20,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; /* @@ -141,12 +142,11 @@ copy_graph(NewGraph& g, Tag) { template void print(Graph& G, Name name) { - typename boost::graph_traits::vertex_iterator ui, uiend; - for (std::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) { - std::cout << name[*ui] << " --> "; - typename boost::graph_traits::adjacency_iterator vi, viend; - for(std::tie(vi, viend) = adjacent_vertices(*ui, G); vi != viend; ++vi) - std::cout << name[*vi] << " "; + for(const auto& u : make_range_pair(vertices(G))) { + std::cout << name[u] << " --> "; + for(const auto& v : make_range_pair(adjacent_vertices(u, G))) + std::cout << name[v] << " "; + std::cout << std::endl; } } diff --git a/example/degree_centrality.cpp b/example/degree_centrality.cpp index 918c6334..e5256177 100644 --- a/example/degree_centrality.cpp +++ b/example/degree_centrality.cpp @@ -14,6 +14,7 @@ #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -55,10 +56,9 @@ main(int argc, char *argv[]) all_degree_centralities(g, cm); // Print the degree centrality of each vertex. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setiosflags(std::ios::left) << std::setw(12) - << g[*i].name << cm[*i] << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setiosflags(std::ios::left) << std::setw(12) + << g[vertex].name << cm[vertex] << std::endl; } return 0; diff --git a/example/dfs-parenthesis.cpp b/example/dfs-parenthesis.cpp index a723f9c5..a52eb185 100644 --- a/example/dfs-parenthesis.cpp +++ b/example/dfs-parenthesis.cpp @@ -7,6 +7,7 @@ //======================================================================= #include #include +#include "range_pair.hpp" char name[] = "abcdefghij"; @@ -35,10 +36,9 @@ main() using namespace boost; GraphvizGraph g; read_graphviz("figs/dfs-example.dot", g); - graph_traits::edge_iterator e, e_end; - for (std::tie(e, e_end) = edges(g); e != e_end; ++e) - std::cout << '(' << name[source(*e, g)] << ' ' - << name[target(*e, g)] << ')' << std::endl; + for (const auto& edge : make_range_pair(edges(g))) + std::cout << '(' << name[source(edge, g)] << ' ' + << name[target(edge, g)] << ')' << std::endl; parenthesis_visitor paren_vis; depth_first_search(g, visitor(paren_vis)); diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index ac7a5563..065b98e8 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -44,9 +45,10 @@ main(int, char *[]) auto indexmap = get(vertex_index, g); auto name = get(vertex_name, g); int c = 0; - for (std::tie(i, iend) = vertices(g); i != iend; ++i, ++c) { - indexmap[*i] = c; - name[*i] = 'A' + c; + for (const auto& vertex : make_range_pair(vertices(g))) { + indexmap[vertex] = c; + name[vertex] = 'A' + c; + ++c; } auto s = vertex(A, g); @@ -56,10 +58,9 @@ main(int, char *[]) dijkstra_shortest_paths(g, s, predecessor_map(p).distance_map(d)); std::cout << "distances and parents:" << std::endl; - graph_traits::vertex_iterator vi, vend; - for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { - std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << "distance(" << name[vertex] << ") = " << d[vertex] << ", "; + std::cout << "parent(" << name[vertex] << ") = " << name[p[vertex]] << std::endl; } std::cout << std::endl; @@ -70,9 +71,7 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - auto e = *ei; + for (const auto& e : make_range_pair(edges(g))) { auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 153832f2..2349d655 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -43,10 +44,9 @@ main(int, char *[]) distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g)))); std::cout << "distances and parents:" << std::endl; - graph_traits::vertex_iterator vi, vend; - for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { - std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << "distance(" << name[vertex] << ") = " << d[vertex] << ", "; + std::cout << "parent(" << name[vertex] << ") = " << name[p[vertex]] << std::endl; } std::cout << std::endl; @@ -58,9 +58,7 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - auto e = *ei; + for (const auto& e : make_range_pair(edges(g))) { auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index b183e292..dab067db 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -47,10 +48,9 @@ main(int, char *[]) distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g)))); std::cout << "distances and parents:" << std::endl; - graph_traits::vertex_iterator vi, vend; - for (std::tie(vi, vend) = vertices(g); vi != vend; ++vi) { - std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; - std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << "distance(" << name[vertex] << ") = " << d[vertex] << ", "; + std::cout << "parent(" << name[vertex] << ") = " << name[p[vertex]] << std::endl; } std::cout << std::endl; @@ -62,9 +62,7 @@ main(int, char *[]) << " ratio=\"fill\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - graph_traits::edge_descriptor e = *ei; + for (const auto& e : make_range_pair(edges(g))) { auto u = source(e, g), v = target(e, g); dot_file << name[u] << " -> " << name[v] << "[label=\"" << get(weightmap, e) << "\""; diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index a30b3833..a1788741 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -14,6 +14,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -75,10 +76,9 @@ main(int argc, char *argv[]) std::tie(r, d) = all_eccentricities(g, dm, em); // Print the closeness centrality of each vertex. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name << get(em, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name << get(em, vertex) << std::endl; } std::cout << "radius: " << r << std::endl; std::cout << "diamter: " << d << std::endl; diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index cd56a4e8..1cc9ace5 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" namespace boost { @@ -20,15 +21,14 @@ namespace boost typename graph_traits::degree_size_type> min_degree_vertex(Graph & g) { - typename graph_traits < Graph >::vertex_descriptor p; - using size_type = typename graph_traits < Graph >::degree_size_type; - auto delta = (std::numeric_limits < size_type >::max)(); - typename graph_traits < Graph >::vertex_iterator i, iend; - for (std::tie(i, iend) = vertices(g); i != iend; ++i) - if (degree(*i, g) < delta) + typename graph_traits::vertex_descriptor p; + using size_type = typename graph_traits::degree_size_type; + auto delta = (std::numeric_limits::max)(); + for(const auto& vertex : make_range_pair(vertices(g))) + if (degree(vertex, g) < delta) { - delta = degree(*i, g); - p = *i; + delta = degree(vertex, g); + p = vertex; } return std::make_pair(p, delta); } @@ -38,9 +38,8 @@ namespace boost typename graph_traits::vertex_descriptor u, OutputIterator result) { - typename graph_traits::adjacency_iterator ai, aend; - for (std::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) - *result++ = *ai; + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + *result++ = vertex; } template < typename Graph, typename VertexIterator, typename OutputIterator > void neighbors(const Graph & g, @@ -71,7 +70,6 @@ namespace boost vertex_descriptor u, v, p, k; edge_descriptor e1, e2; bool inserted; - typename graph_traits::vertex_iterator vi, vi_end; degree_size_type delta, alpha_star, alpha_S_k; std::set S, neighbor_S; std::vector S_star, nonneighbor_S; @@ -83,9 +81,8 @@ namespace boost auto res_cap = get(edge_residual_capacity, flow_g); auto rev_edge = get(edge_reverse, flow_g); - typename graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - u = source(*ei, g), v = target(*ei, g); + for (const auto& edge : make_range_pair(edges(g))) { + u = source(edge, g), v = target(edge, g); std::tie(e1, inserted) = add_edge(u, v, flow_g); cap[e1] = 1; std::tie(e2, inserted) = add_edge(v, u, flow_g); @@ -112,9 +109,9 @@ namespace boost if (alpha_S_k < alpha_star) { alpha_star = alpha_S_k; S_star.clear(); - for (std::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) - if (color[*vi] != Color::white()) - S_star.emplace_back(*vi); + for (const auto& vertex : make_range_pair(vertices(flow_g))) + if (color[vertex] != Color::white()) + S_star.emplace_back(vertex); } S.insert(k); neighbor_S.insert(k); @@ -130,10 +127,9 @@ namespace boost in_S_star[vertex] = true; degree_size_type c = 0; for (const auto& vertex : S_star.begin()) { - typename graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) - if (!in_S_star[target(*ei, g)]) { - *disconnecting_set++ = *ei; + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + if (!in_S_star[target(edge, g)]) { + *disconnecting_set++ = edge; ++c; } } diff --git a/example/edge-function.cpp b/example/edge-function.cpp index fea0c962..7c201e06 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -41,10 +42,9 @@ output_adjacent_vertices(std::ostream & out, typename graph_traits::vertex_descriptor u, const Graph & g, VertexNameMap name_map) { - typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) - out << get(name_map, *vi) << " "; + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + out << get(name_map, vertex) << " "; out << "}" << std::endl; } diff --git a/example/edge_property.cpp b/example/edge_property.cpp index a1a2d92a..01321f14 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -54,6 +54,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -71,30 +72,20 @@ namespace boost { template void print_network(const Graph& G) { - using Viter = typename boost::graph_traits::vertex_iterator ; - using OutEdgeIter = typename boost::graph_traits::out_edge_iterator; - using InEdgeIter = typename boost::graph_traits::in_edge_iterator; - auto capacity = get(edge_mycapacity, G); auto flow = get(edge_myflow, G); - Viter ui, uiend; - std::tie(ui, uiend) = vertices(G); - - for (; ui != uiend; ++ui) { - OutEdgeIter out, out_end; - std::cout << *ui << "\t"; + for (const auto& vertex : make_range_pair(vertices(G))) { + std::cout << vertex << "\t"; - std::tie(out, out_end) = out_edges(*ui, G); - for(; out != out_end; ++out) - std::cout << "--(" << capacity[*out] << ", " << flow[*out] << ")--> " - << target(*out,G) << "\t"; + for (const auto& edge : make_range_pair(out_edges(vertex, G))) + std::cout << "--(" << capacity[edge] << ", " << flow[edge] << ")--> " + << target(edge,G) << "\t"; - InEdgeIter in, in_end; - std::tie(in, in_end) = in_edges(*ui, G); - for(; in != in_end; ++in) - std::cout << "<--(" << capacity[*in] << "," << flow[*in] << ")-- " - << source(*in,G) << "\t"; + std::cout << std::endl << "\t"; + for (const auto& edge : make_range_pair(in_edges(vertex, G))) + std::cout << "<--(" << capacity[edge] << "," << flow[edge] << ")-- " + << source(edge, G) << "\t"; std::cout << std::endl; } @@ -142,12 +133,10 @@ int main(int , char* []) property_map::type flow = get(edge_myflow, G); - boost::graph_traits::vertex_iterator v, v_end; - boost::graph_traits::out_edge_iterator e, e_end; int f = 0; - for (std::tie(v, v_end) = vertices(G); v != v_end; ++v) - for (std::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) - flow[*e] = ++f; + for (const auto& vertex : make_range_pair(vertices(G))) + for (const auto& edge : make_range_pair(out_edges(vertex, G))) + flow[edge] = ++f; std::cout << std::endl << std::endl; remove_edge(6, 8, G); diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index 68cf7f6c..da095a44 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" // Use a DIMACS network flow file as stdin. // edmonds-karp-eg < max_flow.dat @@ -76,13 +77,11 @@ main() std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) - std::cout << "f " << *u_iter << " " << target(*ei, g) << " " - << (capacity[*ei] - residual_capacity[*ei]) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + if (capacity[edge] > 0) + std::cout << "f " << vertex << " " << target(edge, g) << " " + << (capacity[edge] - residual_capacity[edge]) << std::endl; return EXIT_SUCCESS; } diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index ae3a8c9e..3a4c5aeb 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -37,28 +37,22 @@ #include #include #include +#include "range_pair.hpp" template void print_network(Graph& G, Capacity capacity, Flow flow) { - using Viter = typename boost::graph_traits::vertex_iterator ; - using OutEdgeIter = typename boost::graph_traits::out_edge_iterator; - using InEdgeIter = typename boost::graph_traits::in_edge_iterator; - - Viter ui, uiend; - for (std::tie(ui, uiend) = boost::vertices(G); ui != uiend; ++ui) { - OutEdgeIter out, out_end; - std::cout << *ui << "\t"; - - for(std::tie(out, out_end) = boost::out_edges(*ui, G); out != out_end; ++out) - std::cout << "--(" << boost::get(capacity, *out) << ", " - << boost::get(flow, *out) << ")--> " << boost::target(*out,G) << "\t"; + for (const auto& vertex : make_range_pair(vertices(G))) { + std::cout << vertex << "\t"; + + for (const auto& edge : make_range_pair(out_edges(vertex, G))) + std::cout << "--(" << boost::get(capacity, edge) << ", " + << boost::get(flow, edge) << ")--> " << boost::target(edge, G) << "\t"; std::cout << std::endl << "\t"; - InEdgeIter in, in_end; - for(std::tie(in, in_end) = boost::in_edges(*ui, G); in != in_end; ++in) - std::cout << "<--(" << boost::get(capacity, *in) << "," << boost::get(flow, *in) << ")-- " - << boost::source(*in, G) << "\t"; + for (const auto& edge : make_range_pair(in_edges(vertex, G))) + std::cout << "<--(" << boost::get(capacity, edge) << "," << boost::get(flow, edge) << ")-- " + << boost::source(edge, G) << "\t"; std::cout << std::endl; } } diff --git a/example/family_tree.cpp b/example/family_tree.cpp index 03f42135..9c0cff5c 100644 --- a/example/family_tree.cpp +++ b/example/family_tree.cpp @@ -11,6 +11,8 @@ #include #include #include +#include "range_pair.hpp" + enum family { Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N }; int @@ -29,13 +31,12 @@ main() add_edge(Rick, Margaret, g); add_edge(John, Benjamin, g); - graph_traits>::vertex_iterator i, end; graph_traits>::adjacency_iterator ai, a_end; auto index_map = get(vertex_index, g); - for (std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << name[get(index_map, *i)]; - std::tie(ai, a_end) = adjacent_vertices(*i, g); + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << name[get(index_map, vertex)]; + std::tie(ai, a_end) = adjacent_vertices(vertex, g); if (ai == a_end) std::cout << " has no children"; else diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index 777866b7..acab35dd 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -40,6 +40,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -130,12 +131,11 @@ int main(int,char*[]) for (i = make_order.begin(); i != make_order.end(); ++i) { // Walk through the in_edges an calculate the maximum time. if (in_degree (*i, g) > 0) { - Graph::in_edge_iterator j, j_end; int maxdist=0; // Through the order from topological sort, we are sure that every // time we are using here is already initialized. - for (std::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j) - maxdist=(std::max)(time[source(*j, g)], maxdist); + for (const auto& edge : make_range_pair(in_edges(*i, g))) + maxdist=(std::max)(time[source(edge, g)], maxdist); time[*i]=maxdist+1; } } @@ -143,9 +143,8 @@ int main(int,char*[]) std::cout << "parallel make ordering, " << std::endl << "vertices with same group number can be made in parallel" << std::endl; { - graph_traits::vertex_iterator i, iend; - for (std::tie(i,iend) = vertices(g); i != iend; ++i) - std::cout << "time_slot[" << name[*i] << "] = " << time[*i] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << "time_slot[" << name[vertex] << "] = " << time[vertex] << std::endl; } } diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 3755325a..2a7324fd 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" template struct non_zero_degree { @@ -36,9 +37,10 @@ main() graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits::vertex_iterator v, v_end; - for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) - name_map[*v] = name; + for (const auto& vertex : make_range_pair(vertices(G))) { + name_map[vertex] = name; + ++name; + } using E = std::pair; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index 2aec7c31..42046dbd 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "range_pair.hpp" template struct positive_edge_weight { @@ -60,20 +61,18 @@ int main() auto weight = get(edge_weight, g); std::cout << "unfiltered edge_range(C,D)\n"; - graph_traits::out_edge_iterator f, l; - for (std::tie(f, l) = edge_range(C, D, g); f != l; ++f) - std::cout << name[source(*f, g)] << " --" << weight[*f] - << "-> " << name[target(*f, g)] << "\n"; + for (const auto& edge : make_range_pair(edge_range(C, D, g))) + std::cout << name[source(edge, g)] << " --" << weight[edge] + << "-> " << name[target(edge, g)] << "\n"; positive_edge_weight filter(weight); using FGraph = filtered_graph>; FGraph fg(g, filter); std::cout << "filtered edge_range(C,D)\n"; - graph_traits::out_edge_iterator first, last; - for (std::tie(first, last) = edge_range(C, D, fg); first != last; ++first) - std::cout << name[source(*first, fg)] << " --" << weight[*first] - << "-> " << name[target(*first, fg)] << "\n"; + for (const auto& edge : make_range_pair(edge_range(C, D, fg))) + std::cout << name[source(edge, fg)] << " --" << weight[edge] + << "-> " << name[target(edge, fg)] << "\n"; return 0; } diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 3fa3e954..d03c68ed 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -126,10 +127,9 @@ int main(int argc, char* argv[]) (g, position, topo, cooling(progress_cooling(iterations))); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - std::cout << get(vertex_name, g, *vi) << '\t' - << position[*vi][0] << '\t' << position[*vi][1] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << get(vertex_name, g, vertex) << '\t' + << position[vertex][0] << '\t' << position[vertex][1] << std::endl; } return 0; } diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index b0984981..edd27b08 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -11,6 +11,7 @@ #include #include +#include "range_pair.hpp" /* Thanks to Dale Gerdemann for this example, which inspired some @@ -45,15 +46,12 @@ void merge_vertex { using Traits = boost::graph_traits; typename Traits::edge_descriptor e; - typename Traits::out_edge_iterator out_i, out_end; - for (std::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { - e = *out_i; + for (const auto& e : make_range_pair(out_edges(v, g))) { auto targ = target(e, g); add_edge(u, targ, getp(e), g); } - typename Traits::in_edge_iterator in_i, in_end; - for (std::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { - e = *in_i; + + for (const auto& e : make_range_pair(in_edges(v, g))) { auto src = source(e, g); add_edge(src, u, getp(e), g); } @@ -124,13 +122,10 @@ main() auto id = get(vertex_index, g); auto name = get(edge_name, g); - graph_traits::vertex_iterator i, end; - graph_traits::out_edge_iterator ei, edge_end; - - for (std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << id[*i] << " "; - for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << id[vertex] << " "; + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + std::cout << " --" << name[edge] << "--> " << id[target(edge, g)] << " "; std::cout << std::endl; } std::cout << std::endl; @@ -138,10 +133,10 @@ main() std::cout << "merging vertex 1 into vertex 0" << std::endl << std::endl; merge_vertex(0, 1, g, get_edge_name(g)); - for (std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << id[*i] << " "; - for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << id[vertex] << " "; + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + std::cout << " --" << name[edge] << "--> " << id[target(edge, g)] << " "; std::cout << std::endl; } std::cout << std::endl; diff --git a/example/girth.cpp b/example/girth.cpp index cfc8f83e..24e7f20d 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -48,6 +48,7 @@ #include #include #include +#include "range_pair.hpp" using Traits = boost::graph_traits; using vertex_descriptor = Traits::vertex_descriptor; @@ -133,9 +134,8 @@ main() p_map = get(pred_t(), g); c_map = get(color_t(), g); - vertex_iterator i, end; - for (std::tie(i, end) = boost::vertices(g); i != end; ++i) - d_map[*i] = 0; + for (const auto& vertex : make_range_pair(boost::vertices(g))) + d_map[vertex] = 0; std::size_t k = 0; std::size_t girth = (std::numeric_limits::max)(); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index 3c32c1fa..c5f7c817 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -22,10 +23,10 @@ main() const char *vertex_names[] = { "Kubrick", "Clark", "Hal" }; int i = 0; - graph_property_iter_range::iterator v, v_end; - for (std::tie(v, v_end) = get_property_iter_range(g, vertex_name); - v != v_end; ++v, ++i) - *v = vertex_names[i]; + for (auto& vertex : make_range_pair(get_property_iter_range(g, vertex_name))) { + vertex = vertex_names[i]; + ++i; + } std::tie(v, v_end) = get_property_iter_range(g, vertex_name); std::copy(v, v_end, std::ostream_iterator (std::cout, " ")); diff --git a/example/graph.cpp b/example/graph.cpp index 2e0d030e..f3b96d39 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -13,6 +13,7 @@ #include #include +#include "range_pair.hpp" using namespace boost; @@ -27,12 +28,11 @@ using Graph = adjacency_list void print(Graph& g) { - typename Graph::vertex_iterator i, end; - typename Graph::out_edge_iterator ei, edge_end; - for(std::tie(i,end) = vertices(g); i != end; ++i) { - std::cout << *i << " --> "; - for (std::tie(ei,edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << target(*ei, g) << " "; + for (const auto& vertex : make_range_pair(boost::vertices(g))) { + std::cout << vertex << " --> "; + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + std::cout << target(edge, g) << " "; + std::cout << std::endl; } } diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index e09d95a9..a29cfcc9 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "range_pair.hpp" /* @@ -474,20 +475,16 @@ int main (int argc, char const *argv[]) { // Vertex 4: (4, 0) (4, 3) Adjacent vertices 0 3 // 5 vertices std::cout << "Vertices, outgoing edges, and adjacent vertices" << std::endl; - vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; vi++) { - vertex_descriptor u = *vi; + for (const auto& u : make_range_pair(vertices(g))) { std::cout << "Vertex " << u << ": "; // Adjacenct edges - out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ei++) - std::cout << *ei << " "; + for (const auto& edge : make_range_pair(out_edges(u, g))) + std::cout << edge << " "; std::cout << " Adjacent vertices "; // Adjacent vertices // Here we want our adjacency_iterator and not boost::adjacency_iterator. - ::adjacency_iterator ai, ai_end; - for (std::tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ai++) { - std::cout << *ai << " "; + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) { + std::cout << vertex << " "; } std::cout << std::endl; } @@ -504,9 +501,7 @@ int main (int argc, char const *argv[]) { // (4, 0) weight 2 // 5 edges std::cout << "Edges and weights" << std::endl; - edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ei++) { - edge_descriptor e = *ei; + for (const auto& e : make_range_pair(edges(g))) { std::cout << e << " weight " << get(edge_weight, g, e) << std::endl; } std::cout << num_edges(g) << " edges" << std::endl; @@ -536,11 +531,10 @@ int main (int argc, char const *argv[]) { distance_map(dist_pm) ); std::cout << "Dijkstra search from vertex " << source << std::endl; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - vertex_descriptor u = *vi; - std::cout << "Vertex " << u << ": " - << "parent "<< pred[*vi] << ", " - << "distance " << dist[u] + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << "Vertex " << vertex << ": " + << "parent "<< pred[vertex] << ", " + << "distance " << dist[vertex] << std::endl; } } diff --git a/example/in_edges.cpp b/example/in_edges.cpp index 53627c20..fd519b71 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -12,6 +12,7 @@ #include #include +#include "range_pair.hpp" /* Sample Output @@ -38,13 +39,11 @@ int main(int , char* []) add_edge(2, 4, g); add_edge(3, 4, g); - boost::graph_traits::vertex_iterator i, end; - boost::graph_traits::in_edge_iterator ei, edge_end; - - for(std::tie(i,end) = vertices(g); i != end; ++i) { - std::cout << *i << " <-- "; - for (std::tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) - std::cout << source(*ei, g) << " "; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << vertex << " <-- "; + for (const auto& edge : make_range_pair(in_edges(vertex, g))) + std::cout << source(edge, g) << " "; + std::cout << std::endl; } return 0; } diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index e8a76bb9..b239dd9d 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -13,6 +13,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -119,12 +120,11 @@ main(int argc, char *argv[]) std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "vertex"; std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "excluding"; std::cout << std::setw(12) << std::setiosflags(std::ios::left) << "including" << std::endl; - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name - << std::setw(12) << get(exmap, *i) - << std::setw(12) << get(inmap, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name + << std::setw(12) << get(exmap, vertex) + << std::setw(12) << get(inmap, vertex) << std::endl; } std::cout << "small world (excluding self-loops): " << ex << std::endl; std::cout << "small world (including self-loops): " << in << std::endl; diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index 12c0580b..588ebde9 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -13,6 +13,7 @@ #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -60,10 +61,8 @@ main(int argc, char *argv[]) all_prestige_values(g, pm); // Print the degree centrality of each vertex - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - auto v = *i; - std::cout << std::setiosflags(std::ios::left) << std::setw(12) + for(const auto& v : make_range_pair(vertices(g))) { + std::cout << std::setiosflags(std::ios::left) << std::setw(12) << g[v].name << "\t" << im[v] << "\t" << pm[v] << std::endl; diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index d4cb2b42..6da7a754 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -9,6 +9,7 @@ #include #include +#include "range_pair.hpp" /* Sample output: @@ -33,16 +34,17 @@ main() v1_index_map = get(vertex_index, g1), v2_index_map = get(vertex_index, g2); - graph_traits::vertex_iterator i, end; int id = 0; - for (std::tie(i, end) = vertices(g1); i != end; ++i, ++id) { - put(v1_index_map, *i, id); - v1[id] = *i; + for (const auto& vertex : make_range_pair(vertices(g1))) { + put(v1_index_map, vertex, id); + v1[id] = vertex; + ++id; } id = 0; - for (std::tie(i, end) = vertices(g2); i != end; ++i, ++id) { - put(v2_index_map, *i, id); - v2[id] = *i; + for (const auto& vertex : make_range_pair(vertices(g2))) { + put(v2_index_map, vertex, id); + v2[id] = vertex; + ++id; } add_edge(v1[0], v1[1], g1); add_edge(v1[1], v1[2], g1); add_edge(v1[0], v1[2], g1); diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index e0f6b06c..7f4a12c2 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -42,9 +43,8 @@ main() int weights[] = { 0, 0, 0, 0, 0, 3, -4, 8, 1, 7, 4, -5, 2, 6 }; int *wp = weights; - graph_traits::edge_iterator e, e_end; - for (std::tie(e, e_end) = edges(g); e != e_end; ++e) - w[*e] = *wp++; + for (const auto& edge : make_range_pair(edges(g))) + w[edge] = *wp++; std::vectord(V, (std::numeric_limits < int>::max)()); int D[V][V]; @@ -72,10 +72,9 @@ main() << "ratio=\"fill\"\n" << "edge[style=\"bold\"]\n" << "node[shape=\"circle\"]\n"; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - fout << source(*ei, g) << " -> " << target(*ei, g) - << "[label=" << get(edge_weight, g)[*ei] << "]\n"; + for (const auto& edge : make_range_pair(edges(g))) + fout << source(edge, g) << " -> " << target(edge, g) + << "[label=" << get(edge_weight, g)[edge] << "]\n"; fout << "}\n"; return 0; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 3d2091ca..e1339d7e 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "range_pair.hpp" #include using namespace boost; @@ -106,10 +107,9 @@ main() breadth_first_search(g, src, visitor(record_bacon_number(&bacon_number[0]))); - graph_traits::vertex_iterator i, end; - for (std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << actor_name[*i] << " has a Bacon number of " - << bacon_number[*i] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << actor_name[vertex] << " has a Bacon number of " + << bacon_number[vertex] << std::endl; } return 0; diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index 75b4e862..62c0aa83 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "range_pair.hpp" struct vertex_properties { std::string name; @@ -71,10 +72,9 @@ int main() // Get the vertex for Kevin Bacon Vertex src; - graph_traits::vertex_iterator i, end; - for (std::tie(i, end) = vertices(g); i != end; ++i) - if (g[*i].name == "Kevin Bacon") - src = *i; + for (const auto& vertex : make_range_pair(vertices(g))) + if (g[vertex].name == "Kevin Bacon") + src = vertex; // Set Kevin's number to zero bacon_number[src] = 0; @@ -83,9 +83,9 @@ int main() breadth_first_search(g, src, visitor(bacon_number_recorder(&bacon_number[0]))); - for (std::tie(i, end) = vertices(g); i != end; ++i) - std::cout << g[*i].name << " has a Bacon number of " - << bacon_number[*i] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << g[vertex].name << " has a Bacon number of " + << bacon_number[vertex] << std::endl; return 0; } diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index da233170..b17c03b8 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "range_pair.hpp" /* Sample Output @@ -58,11 +59,9 @@ int main(int , char* []) for (int i = 0; i < 14; ++i) add_edge(edges[i].first, edges[i].second, G); - graph_traits::vertex_iterator ui, ui_end; - auto deg = get(vertex_degree, G); - for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) - deg[*ui] = degree(*ui, G); + for (const auto& vertex : make_range_pair(vertices(G))) + deg[vertex] = degree(vertex, G); auto index_map = get(vertex_index, G); diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index cbf7c1f6..14528ef1 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -171,10 +172,9 @@ template return true; bool deadend = true; - typename graph_traits::adjacency_iterator i, end; - for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) - if (get(time_map, *i) == -1) { - S.push(std::make_pair(time_stamp + 1, *i)); + for (const auto& vertex : make_range_pair(adjacent_vertices(x, g))) + if (get(time_map, vertex) == -1) { + S.push(std::make_pair(time_stamp + 1, vertex)); deadend = false; } @@ -197,9 +197,8 @@ template int number_of_successors(Vertex x, Graph & g, TimePropertyMap time_map) { int s_x = 0; - typename graph_traits::adjacency_iterator i, end; - for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) - if (get(time_map, *i) == -1) + for (const auto& vertex : make_range_pair(adjacent_vertices(x, g))) + if (get(time_map, vertex) == -1) ++s_x; return s_x; } @@ -225,12 +224,11 @@ template // Put adjacent vertices into a local priority queue std::priority_queue, compare_first> Q; - typename graph_traits::adjacency_iterator i, end; int num_succ; - for (std::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) - if (get(time_map, *i) == -1) { - num_succ = number_of_successors(*i, g, time_map); - Q.push(std::make_pair(num_succ, *i)); + for (const auto& vertex : make_range_pair(adjacent_vertices(x, g))) + if (get(time_map, vertex) == -1) { + num_succ = number_of_successors(vertex, g, time_map); + Q.push(std::make_pair(num_succ, vertex)); } bool deadend = Q.empty(); // move vertices from local priority queue to the stack diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index cbcc824a..28acfb85 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -55,15 +56,14 @@ main() << " size=\"3,3\"\n" << " ratio=\"filled\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; - graph_traits::edge_iterator eiter, eiter_end; - for (std::tie(eiter, eiter_end) = edges(g); eiter != eiter_end; ++eiter) { - fout << source(*eiter, g) << " -- " << target(*eiter, g); - if (std::find(spanning_tree.begin(), spanning_tree.end(), *eiter) + for (const auto& edge : make_range_pair(edges(g))) { + fout << source(edge, g) << " -- " << target(edge, g); + if (std::find(spanning_tree.begin(), spanning_tree.end(), edge) != spanning_tree.end()) - fout << "[color=\"black\", label=\"" << get(edge_weight, g, *eiter) + fout << "[color=\"black\", label=\"" << get(edge_weight, g, edge) << "\"];\n"; else - fout << "[color=\"gray\", label=\"" << get(edge_weight, g, *eiter) + fout << "[color=\"gray\", label=\"" << get(edge_weight, g, edge) << "\"];\n"; } fout << "}\n"; diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 7076bfab..480f5108 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -23,11 +24,10 @@ main() property>; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - int weight = lexical_cast(edge_attr_map[*ei]["label"]); + for (const auto& edge : make_range_pair(edges(g_dot))) { + int weight = lexical_cast(edge_attr_map[edge]["label"]); property edge_property(weight); - add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); + add_edge(source(edge, g_dot), target(edge, g_dot), edge_property, g); } std::vector::edge_descriptor> mst; diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index 66ec5638..91b0e853 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -15,6 +15,7 @@ #include #include +#include "range_pair.hpp" using namespace boost; @@ -50,9 +51,8 @@ int main(int argc, char** argv) // Initialize the interior edge index auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; - graph_traits::edge_iterator ei, ei_end; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); // Test for planarity - we know it is not planar, we just want to diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index 8b58fe84..f2e052df 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -70,19 +71,15 @@ main() auto name = get(vertex_name, g); struct stat stat_buf; - graph_traits::vertex_descriptor u; - using vertex_iter_t = graph_traits::vertex_iterator; - std::pair p; - for (p = vertices(g); p.first != p.second; ++p.first) { - u = *p.first; + for (const auto& u : make_range_pair(vertices(g))) { if (stat(name[u].c_str(), &stat_buf) != 0) std::cerr << "error in stat() for file " << name[u] << std::endl; put(mod_time_map, u, stat_buf.st_mtime); } - for (p = vertices(g); p.first != p.second; ++p.first) { - std::cout << name[*p.first] << " was last modified at " - << ctime(&mod_time_map[*p.first]); + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << name[vertex] << " was last modified at " + << ctime(&mod_time_map[vertex]); } assert(num_vertices(g) == 15); assert(num_edges(g) == 19); diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index 96f5ef82..78ff9cbf 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -21,8 +21,7 @@ main() g.new_node("Amphitryon"); using NodeMap = property_map::type; auto node_name_map = get(vertex_all, g); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - std::cout << node_name_map[*vi] << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << node_name_map[vertex] << std::endl; return EXIT_SUCCESS; } diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 39cd36b4..8d7e4cb9 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -90,11 +91,10 @@ compute_loop_extent(typename graph_traits < make_iterator_property_map(reachable_to_tail.begin(), get(vertex_index, g), c)); - typename graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (reachable_from_head[*vi] != Color::white() - && reachable_to_tail[*vi] != Color::white()) - loop_set.insert(*vi); + for (const auto& vertex : make_range_pair(vertices(g))) + if (reachable_from_head[vertex] != Color::white() + && reachable_to_tail[vertex] != Color::white()) + loop_set.insert(vertex); } @@ -130,7 +130,6 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); auto eattr_map = get(edge_attribute, g); - graph_traits::edge_iterator ei, ei_end; for (auto i = loops.begin(); i != loops.end(); ++i) { std::vector in_loop(num_vertices(g), false); @@ -138,9 +137,9 @@ main(int argc, char *argv[]) vattr_map[*j]["color"] = "gray"; in_loop[*j] = true; } - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - if (in_loop[source(*ei, g)] && in_loop[target(*ei, g)]) - eattr_map[*ei]["color"] = "gray"; + for (const auto& edge : make_range_pair(edges(g))) + if (in_loop[source(edge, g)] && in_loop[target(edge, g)]) + eattr_map[edge]["color"] = "gray"; } std::ofstream loops_out(argv[2]); @@ -150,21 +149,20 @@ main(int argc, char *argv[]) << "size=\"3,3\"\n" << "ratio=\"fill\"\n" << "shape=\"box\"\n"; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - loops_out << *vi << "["; - for (auto ai = vattr_map[*vi].begin(); - ai != vattr_map[*vi].end(); ++ai) { + for (const auto& vertex : make_range_pair(vertices(g))) { + loops_out << vertex << "["; + for (auto ai = vattr_map[vertex].begin(); + ai != vattr_map[vertex].end(); ++ai) { loops_out << ai->first << "=" << ai->second; - if (next(ai) != vattr_map[*vi].end()) + if (next(ai) != vattr_map[vertex].end()) loops_out << ", "; } loops_out<< "]"; } - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; - auto& attr_map = eattr_map[*ei]; + for (const auto& edge : make_range_pair(edges(g))) { + loops_out << source(edge, g) << " -> " << target(edge, g) << "["; + auto& attr_map = eattr_map[edge]; for (auto eai = attr_map.begin(); eai != attr_map.end(); ++eai) { loops_out << eai->first << "=" << eai->second; diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index 80f681ae..f9481cda 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -16,6 +16,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -46,9 +47,8 @@ int main(int argc, char** argv) //Initialize the interior edge index auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; - graph_traits::edge_iterator ei, ei_end; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); //Test for planarity; compute the planar embedding as a side-effect @@ -80,8 +80,8 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); // Re-size the storage for the biconnected components, since we // just added a few edges diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index e7484546..057d261f 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "range_pair.hpp" @@ -69,9 +70,8 @@ int main(int argc, char** argv) //Initialize the interior edge index auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; - graph_traits::edge_iterator ei, ei_end; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); //Test for planarity; compute the planar embedding as a side-effect @@ -90,8 +90,8 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); //Test for planarity again; compute the planar embedding as a side-effect @@ -112,8 +112,8 @@ int main(int argc, char** argv) // Re-initialize the edge index, since we just added a few edges edge_count = 0; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); // Test for planarity one final time; compute the planar embedding as a // side-effect diff --git a/example/matching_example.cpp b/example/matching_example.cpp index 0e909489..a84fb878 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -12,6 +12,7 @@ #include #include +#include "range_pair.hpp" using namespace boost; @@ -81,11 +82,10 @@ int main() std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) << std::endl; std::cout << "The matching is:" << std::endl; - - graph_traits::vertex_iterator vi, vi_end; - for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) - if (mate[*vi] != graph_traits::null_vertex() && *vi < mate[*vi]) - std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl; + + for(const auto& vertex : make_range_pair(vertices(g))) + if (mate[vertex] != graph_traits::null_vertex() && vertex < mate[vertex]) + std::cout << "{" << vertex << ", " << mate[vertex] << "}" << std::endl; std::cout << std::endl; @@ -109,9 +109,9 @@ int main() std::cout << "The matching is:" << std::endl; - for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) - if (mate[*vi] != graph_traits::null_vertex() && *vi < mate[*vi]) - std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) + if (mate[vertex] != graph_traits::null_vertex() && vertex < mate[vertex]) + std::cout << "{" << vertex << ", " << mate[vertex] << "}" << std::endl; return 0; } diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 1109dc60..9bac63a2 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "range_pair.hpp" // Use a DIMACS network flow file as stdin. // max_flow < max_flow.dat @@ -80,13 +81,11 @@ main() std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) - std::cout << "f " << *u_iter << " " << target(*ei, g) << " " - << (capacity[*ei] - residual_capacity[*ei]) << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + if (capacity[edge] > 0) + std::cout << "f " << vertex << " " << target(edge, g) << " " + << (capacity[edge] - residual_capacity[edge]) << std::endl; return 0; } diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index 14dfb7ca..96fc5108 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -13,6 +13,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -75,10 +76,9 @@ main(int argc, char *argv[]) // Print the mean geodesic distance of each vertex and finally, // the graph itself. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name << get(gm, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name << get(gm, vertex) << std::endl; } std::cout << "small world distance: " << sw << std::endl; diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index fb35efb4..d26ebea3 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -88,16 +88,16 @@ main(int , char* []) std::cout << "distances from start vertex:" << std::endl; graph_traits::vertex_iterator vi, vend; - for(std::tie(vi,vend) = vertices(G); vi != vend; ++vi) - std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << std::endl; + for(const auto& vertex : make_range_pair(vertices(G))) + std::cout << "distance(" << name[vertex] << ") = " << d[vertex] << std::endl; std::cout << std::endl; std::cout << "min-max paths tree" << std::endl; adjacency_list<> tree(num_nodes); - for(std::tie(vi,vend) = vertices(G); vi != vend; ++vi) - if (*vi != p[*vi]) - add_edge(p[*vi], *vi, tree); + for(const auto& vertex : make_range_pair(vertices(G))) + if (vertex != p[vertex]) + add_edge(p[vertex], vertex, tree); print_graph(tree, name); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index a24b1a48..e9f2f4ca 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -47,8 +48,6 @@ void modify_demo(MutableGraph& g) typename GraphTraits::vertex_descriptor u, v, w; edge_descriptor e, e1, e2; auto name_map = get(edge_name, g); - bool added; - typename GraphTraits::vertex_iterator vi, vi_end; { v = add_vertex(g); @@ -182,11 +181,10 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (const auto & vertex : make_range_pair(vertices(g))) { typename GraphTraits::adjacency_iterator ai, ai_end; - for (std::tie(ai, ai_end) = adjacent_vertices(*vi, g); - ai != ai_end; ++ai) - assert(*ai != u); + for (const auto& adjacent_vertex : make_range_pair(adjacent_vertices(vertex, g))) + assert(adjacent_vertex != vertex); } } } diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index a5494c16..bf5511e2 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -13,6 +13,7 @@ #include #include +#include "range_pair.hpp" /* Sample output: @@ -93,12 +94,10 @@ main() auto id = get(vertex_index, g); auto name = get(edge_name, g); - graph_traits::vertex_iterator i, end; - graph_traits::out_edge_iterator ei, edge_end; - for (std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << id[*i] << " "; - for (std::tie(ei, edge_end) = out_edges(*i, g); ei != edge_end; ++ei) - std::cout << " --" << name[*ei] << "--> " << id[target(*ei, g)] << " "; + for (const auto& vertex : make_range_pair(vertices(g))) { + std::cout << id[vertex] << " "; + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + std::cout << " --" << name[edge] << "--> " << id[target(edge, g)] << " "; std::cout << std::endl; } std::cout << std::endl; diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 353b891e..1aa4fb86 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -9,6 +9,7 @@ #include // for read/write_graphviz() #include #include +#include "range_pair.hpp" namespace boost { enum graph_color_t { graph_color = 5556 }; @@ -41,18 +42,16 @@ main() property>; using vertex_descriptor = graph_traits::vertex_descriptor; Graph g(num_vertices(g_dot)); - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - auto weight = get(edge_weight, g_dot, *ei); + for (const auto& edge : make_range_pair(edges(g_dot))) { + auto weight = get(edge_weight, g_dot, edge); property edge_property(weight); - add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); + add_edge(source(edge, g_dot), target(edge, g_dot), edge_property, g); } vertex_descriptor router_six; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) - if ("RT6" == get(vertex_name, g_dot, *vi)) { - router_six = *vi; + for (const auto& vertex : make_range_pair(vertices(g_dot))) + if ("RT6" == get(vertex_name, g_dot, vertex)) { + router_six = vertex; break; } @@ -89,10 +88,10 @@ main() std::ofstream rtable("routing-table.dat"); rtable << "Dest Next Hop Total Cost" << std::endl; - for (std::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) - if (parent[*vi] != *vi) { - rtable << get(vertex_name, g_dot, *vi) << " "; - vertex_descriptor v = *vi, child; + for (const auto& vertex : make_range_pair(vertices(g_dot))) + if (parent[vertex] != vertex) { + rtable << get(vertex_name, g_dot, vertex) << " "; + vertex_descriptor v = vertex, child; int path_cost = 0; property_map::type weight_map = get(edge_weight, g); diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index f4813cc9..47872157 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -14,6 +14,7 @@ #include #include #include // for default_dfs_visitor +#include "range_pair.hpp" namespace std { @@ -57,15 +58,14 @@ dfs_v2(const Graph & g, using ColorT = color_traits; color[u] = ColorT::gray(); vis.discover_vertex(u, g); - typename graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) - if (color[target(*ei, g)] == ColorT::white()) { - vis.tree_edge(*ei, g); - dfs_v2(g, target(*ei, g), color, vis); - } else if (color[target(*ei, g)] == ColorT::gray()) - vis.back_edge(*ei, g); + for (const auto& edge : make_range_pair(out_edges(u, g))) + if (color[target(edge, g)] == ColorT::white()) { + vis.tree_edge(edge, g); + dfs_v2(g, target(edge, g), color, vis); + } else if (color[target(edge, g)] == ColorT::gray()) + vis.back_edge(edge, g); else - vis.forward_or_cross_edge(*ei, g); + vis.forward_or_cross_edge(edge, g); color[u] = ColorT::black(); vis.finish_vertex(u, g); } @@ -75,12 +75,11 @@ generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) { using ColorValue = typename property_traits ::value_type; using ColorT = color_traits ; - typename graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - color[*vi] = ColorT::white(); - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (color[*vi] == ColorT::white()) - dfs_v2(g, *vi, color, vis); + for (const auto& vertex : make_range_pair(vertices(g))) + color[vertex] = ColorT::white(); + for (const auto& vertex : make_range_pair(vertices(g))) + if (color[vertex] == ColorT::white()) + dfs_v2(g, vertex, color, vis); } @@ -155,41 +154,37 @@ main() { std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - name_in >> name_map[*vi]; - compile_cost_in >> compile_cost_map[*vi]; + for (const auto& vertex : make_range_pair(vertices(g))) { + name_in >> name_map[vertex]; + compile_cost_in >> compile_cost_map[vertex]; } } std::vector topo_order(num_vertices(g)); topo_sort(g, topo_order.rbegin(), color_map); - graph_traits::vertex_iterator i, i_end; - graph_traits::adjacency_iterator vi, vi_end; - // find source vertices with zero in-degree by marking all vertices with incoming edges - for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) - color_map[*i] = white_color; - for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) - for (std::tie(vi, vi_end) = adjacent_vertices(*i, g); vi != vi_end; ++vi) - color_map[*vi] = black_color; + for (const auto& vertex : make_range_pair(vertices(g))) + color_map[vertex] = white_color; + for (const auto& vertex : make_range_pair(vertices(g))) + for (const auto& vertex_adjacent : make_range_pair(adjacent_vertices(vertex, g))) + color_map[vertex_adjacent] = black_color; // initialize distances to zero, or for source vertices, to the compile cost - for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) - if (color_map[*i] == white_color) - distance_map[*i] = compile_cost_map[*i]; + for (const auto& vertex : make_range_pair(vertices(g))) + if (color_map[vertex] == white_color) + distance_map[vertex] = compile_cost_map[vertex]; else - distance_map[*i] = 0; + distance_map[vertex] = 0; std::vector::iterator ui; for (ui = topo_order.begin(); ui != topo_order.end(); ++ui) { vertex_t u = * ui; - for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) - if (distance_map[*vi] < distance_map[u] + compile_cost_map[*vi]) - distance_map[*vi] = distance_map[u] + compile_cost_map[*vi]; + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + if (distance_map[vertex] < distance_map[u] + compile_cost_map[vertex]) + distance_map[vertex] = distance_map[u] + compile_cost_map[vertex]; } graph_property_iter_range < file_dep_graph2, diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index 57d91820..9fc017df 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -15,6 +15,7 @@ #include #include +#include "range_pair.hpp" using namespace boost; @@ -92,9 +93,8 @@ int main(int argc, char** argv) // Initialize the interior edge index auto e_index = get(edge_index, g); graph_traits::edges_size_type edge_count = 0; - graph_traits::edge_iterator ei, ei_end; - for(std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - put(e_index, *ei, edge_count++); + for(const auto& edge : make_range_pair(edges(g))) + put(e_index, edge, edge_count++); // Test for planarity - we know it is planar, we just want to diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index b6079dc4..12f4294f 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -12,6 +12,8 @@ #include #include #include +#include "range_pair.hpp" + int main() { @@ -23,11 +25,10 @@ main() property>; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - auto weight = lexical_cast(edge_attr_map[*ei]["label"]); + for (const auto& edge : make_range_pair(edges(g_dot))) { + auto weight = lexical_cast(edge_attr_map[edge]["label"]); property edge_property(weight); - add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); + add_edge(source(edge, g_dot), target(edge, g_dot), edge_property, g); } using Vertex = graph_traits < Graph >::vertex_descriptor; diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index ce0df7b6..4a3ceb85 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -41,10 +42,9 @@ output_adjacent_vertices(std::ostream & out, typename graph_traits::vertex_descriptor u, const Graph & g, VertexNameMap name_map) { - typename graph_traits::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) - out << get(name_map, *vi) << " "; + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + out << get(name_map, vertex) << " "; out << "}" << std::endl; } diff --git a/example/print-edges.cpp b/example/print-edges.cpp index b4616d3c..13d0d7e0 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -40,10 +41,9 @@ template void print_dependencies(std::ostream & out, const Graph & g, VertexNameMap name_map) { - typename graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - out << get(name_map, source(*ei, g)) << " -$>$ " - << get(name_map, target(*ei, g)) << std::endl; + for (const auto& edge : make_range_pair(edges(g))) + out << get(name_map, source(edge, g)) << " -$>$ " + << get(name_map, target(edge, g)) << std::endl; } diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index fcf84eb1..986996b4 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -41,10 +42,9 @@ output_in_edges(std::ostream & out, const Graph & g, typename graph_traits::vertex_descriptor v, VertexNameMap name_map) { - typename graph_traits::in_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) - out << get(name_map, source(*ei, g)) << " -> " - << get(name_map, target(*ei, g)) << std::endl; + for (const auto& edge : make_range_pair(in_edges(v, g))) + out << get(name_map, source(edge, g)) << " -> " + << get(name_map, target(edge, g)) << std::endl; } template class name_equals_t { diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index beefc4a5..2a488178 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -41,10 +42,9 @@ output_out_edges(std::ostream & out, const Graph & g, typename graph_traits::vertex_descriptor u, VertexNameMap name_map) { - typename graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) - out << get(name_map, source(*ei, g)) << " -> " - << get(name_map, target(*ei, g)) << std::endl; + for (const auto& edge : make_range_pair(out_edges(u, g))) + out << get(name_map, source(edge, g)) << " -> " + << get(name_map, target(edge, g)) << std::endl; } template class name_equals_t { diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index 37310bb2..55562e42 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" // Use a DIMACS network flow file as stdin. // push-relabel-eg < max_flow.dat @@ -62,21 +63,19 @@ main() #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 auto indexmap = get(vertex_index, g); - long flow = push_relabel_max_flow(g, s, t, capacity, residual_capacity, rev, + auto flow = push_relabel_max_flow(g, s, t, capacity, residual_capacity, rev, indexmap); #else - long flow = push_relabel_max_flow(g, s, t); + auto flow = push_relabel_max_flow(g, s, t); #endif std::cout << "c The total flow:" << std::endl; std::cout << "s " << flow << std::endl << std::endl; std::cout << "c flow values:" << std::endl; - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (std::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (std::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) - std::cout << "f " << *u_iter << " " << target(*ei, g) << " " - << (capacity[*ei] - residual_capacity[*ei]) << std::endl; + for (const auto& vertex : make_range_pair(vertices(g))) + for (const auto& edge : make_range_pair(out_edges(vertex, g))) + if (capacity[edge] > 0) + std::cout << "f " << vertex << " " << target(edge, g) << " " + << (capacity[edge] - residual_capacity[edge]) << std::endl; return EXIT_SUCCESS; } diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 19c41c86..16d13752 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -45,9 +45,8 @@ template void print_trans_delays(const Graph & g, TransDelayMap trans_delay_map, VertexNameMap name_map) { - typename graph_traits::edge_iterator first, last; - for (std::tie(first, last) = edges(g); first != last; ++first) { - print_trans_delay(*first, g, trans_delay_map, name_map); + for (const auto& edge : make_range_pair(edges(g))) { + print_trans_delay(edge, g, trans_delay_map, name_map); std::cout << std::endl; } } diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 1ff3a3ac..588b1f41 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -14,6 +14,7 @@ #include // for std::tie #include #include +#include "range_pair.hpp" using namespace boost; @@ -28,11 +29,8 @@ template struct exercise_vertex { // Write out the outgoing edges std::cout << "\tout-edges: "; - typename graph_traits::out_edge_iterator out_i, out_end; - for (std::tie(out_i, out_end) = out_edges(v, g); - out_i != out_end; ++out_i) + for (const auto& e : make_range_pair(out_edges(v, g))) { - auto e = *out_i; auto src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; @@ -41,10 +39,8 @@ template struct exercise_vertex { // Write out the incoming edges std::cout << "\tin-edges: "; - typename graph_traits::in_edge_iterator in_i, in_end; - for (std::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) + for (const auto& e : make_range_pair(in_edges(v, g))) { - auto e = *in_i; Vertex src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; @@ -53,9 +49,8 @@ template struct exercise_vertex { // Write out all adjacent vertices std::cout << "\tadjacent vertices: "; - typename graph_traits::adjacency_iterator ai, ai_end; - for (std::tie(ai,ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) - std::cout << name[get(vertex_id, *ai)] << " "; + for (const auto& vertex : make_range_pair(adjacent_vertices(v, g))) + std::cout << name[get(vertex_id, vertex)] << " "; std::cout << std::endl; } Graph& g; @@ -107,15 +102,14 @@ int main(int,char*[]) std::cout << "vertices(g) = "; using vertex_iter = graph_traits::vertex_iterator; std::pair vp; - for (vp = vertices(g); vp.first != vp.second; ++vp.first) - std::cout << name[get(vertex_id, *vp.first)] << " "; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << name[get(vertex_id, vertex)] << " "; std::cout << std::endl; std::cout << "edges(g) = "; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) - std::cout << "(" << name[get(vertex_id, source(*ei, g))] - << "," << name[get(vertex_id, target(*ei, g))] << ") "; + for (const auto& edge : make_range_pair(edges(g))) + std::cout << "(" << name[get(vertex_id, source(edge, g))] + << "," << name[get(vertex_id, target(edge, g))] << ") "; std::cout << std::endl; std::for_each(vertices(g).first, vertices(g).second, diff --git a/example/range_pair.hpp b/example/range_pair.hpp new file mode 100644 index 00000000..864760cc --- /dev/null +++ b/example/range_pair.hpp @@ -0,0 +1,48 @@ +//======================================================================= +// Copyright 2016 Murray Cumming +// Authors: Murray Cumming +// +// 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_GRAPH_EDGE_LIST_HPP +#define BOOST_GRAPH_EDGE_LIST_HPP + +// Inspired by: +// https://cplusplusmusings.wordpress.com/2013/04/14/range-based-for-loops-and-pairs-of-iterators/ +template +class range_pair +{ +public: + explicit range_pair(T_Pair pair) + : pair_(pair) + {} + + range_pair(const range_pair& src) = default; + range_pair& operator=(const range_pair& src) = default; + + range_pair(range_pair&& src) = default; + range_pair& operator=(range_pair&& src) = default; + + typename T_Pair::first_type + begin() const + { return pair_.first; } + + typename T_Pair::second_type + end() const + { return pair_.second; } + +private: + T_Pair pair_; +}; + +template +range_pair make_range_pair(T_Pair pair) +{ + return range_pair(pair); +} + +#endif //BOOST_GRAPH_EDGE_LIST_HPP + diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 35d0c689..0f503a63 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "range_pair.hpp" int main(int argc, char *argv[]) @@ -36,11 +37,10 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); - graph_traits::vertex_iterator i, i_end; - for (std::tie(i, i_end) = vertices(g); i != i_end; ++i) - if (reachable_from_head[*i] != Color::white()) { - vattr_map[*i]["color"] = "gray"; - vattr_map[*i]["style"] = "filled"; + for (const auto& vertex : make_range_pair(vertices(g))) + if (reachable_from_head[vertex] != Color::white()) { + vattr_map[vertex]["color"] = "gray"; + vattr_map[vertex]["style"] = "filled"; } std::ofstream loops_out(argv[2]); @@ -50,23 +50,21 @@ main(int argc, char *argv[]) << "size=\"3,3\"\n" << "ratio=\"fill\"\n" << "shape=\"box\"\n"; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - loops_out << *vi << "["; - for (auto ai = vattr_map[*vi].begin(); - ai != vattr_map[*vi].end(); ++ai) { + for (const auto& vertex : make_range_pair(vertices(g))) { + loops_out << vertex << "["; + for (auto ai = vattr_map[vertex].begin(); + ai != vattr_map[vertex].end(); ++ai) { loops_out << ai->first << "=" << ai->second; - if (next(ai) != vattr_map[*vi].end()) + if (next(ai) != vattr_map[vertex].end()) loops_out << ", "; } loops_out<< "]"; } property_map::type eattr_map = get(edge_attribute, g); - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; - std::map& attr_map = eattr_map[*ei]; + for (const auto& edge : make_range_pair(edges(g))) { + loops_out << source(edge, g) << " -> " << target(edge, g) << "["; + std::map& attr_map = eattr_map[edge]; for (auto eai = attr_map.begin(); eai != attr_map.end(); ++eai) { loops_out << eai->first << "=" << eai->second; diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index 3948b0e1..615a2a05 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -48,18 +48,17 @@ main(int argc, char *argv[]) << " node [shape=\"box\"];\n" << " edge [style=\"bold\"];\n"; auto vattr_map = get(vertex_attribute, g); - graph_traits::vertex_iterator i, i_end; - for (std::tie(i, i_end) = vertices(g_in); i != i_end; ++i) { - loops_out << *i << "[label=\"" << vattr_map[*i]["label"] + for (const auto& vertex : make_range_pair(vertices(g_in))) { + loops_out << vertex << "[label=\"" << vattr_map[vertex]["label"] << "\""; - if (reachable_to_tail[*i] != Color::white()) { + if (reachable_to_tail[vertex] != Color::white()) { loops_out << ", color=\"gray\", style=\"filled\""; } loops_out << "]\n"; } - graph_traits::edge_iterator e, e_end; - for (std::tie(e, e_end) = edges(g_in); e != e_end; ++e) - loops_out << source(*e, g) << " -> " << target(*e, g) << ";\n"; + + for (const auto& edge : make_range_pair(edges(g_in))) + loops_out << source(edge, g) << " -> " << target(edge, g) << ";\n"; loops_out << "}\n"; return EXIT_SUCCESS; } diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 783dbb35..541005f3 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "range_pair.hpp" /************************************* @@ -66,9 +67,7 @@ int main() no_property, property>>; - - using out_edge_iterator = graph_traits::out_edge_iterator; - using edge_descriptor = graph_traits::edge_descriptor; + using vertex_descriptor = graph_traits::vertex_descriptor; Graph g; @@ -87,9 +86,7 @@ int main() tCapMapValue augmented_flow = 0; //we take the source node and check for each outgoing edge e which has a target(p) if we can augment that path - out_edge_iterator oei,oe_end; - for(std::tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ - auto from_source = *oei; + for(const auto& from_source : make_range_pair(out_edges(s, g))){ auto v = target(from_source, g); edge_descriptor to_sink; bool is_there; diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 7c00c38d..d75b4622 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" /* Sample output: @@ -78,9 +79,8 @@ main() weight = get(edge_weight, g); int w = 0; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - weight[*ei] = ++w; + for (const auto& edge : make_range_pair(edges(g))) + weight[edge] = ++w; auto indexmap = get(vertex_index, g); diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 50e0d9a8..1c613f16 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -77,9 +78,8 @@ main() weight = get(edge_weight, g); int w = 0; - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) - weight[*ei] = ++w; + for (const auto& edge : make_range_pair(edges(g))) + weight[edge] = ++w; std::cout << "original graph:" << std::endl; print_graph(g, get(vertex_index, g)); diff --git a/example/roget_components.cpp b/example/roget_components.cpp index 01567c69..a1fa5c20 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" #define specs(v) \ (filename ? index_map[v] : v->cat_no) << " " << v->name @@ -69,15 +70,14 @@ int main(int argc, char* argv[]) std::vector> strong_comp(num_comp); // First add representative vertices to each component's list - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (root[*vi] == *vi) - strong_comp[comp[index_map[*vi]]].emplace_back(*vi); + for (const auto& vertex : make_range_pair(vertices(g))) + if (root[vertex] == vertex) + strong_comp[comp[index_map[vertex]]].emplace_back(vertex); // Then add the other vertices of the component - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (root[*vi] != *vi) - strong_comp[comp[index_map[*vi]]].emplace_back(*vi); + for (const auto& vertex : make_range_pair(vertices(g))) + if (root[vertex] != vertex) + strong_comp[comp[index_map[vertex]]].emplace_back(vertex); // We do not print out the "from" and "to" information as Knuth // does because we no longer have easy access to that information @@ -114,9 +114,8 @@ int main(int argc, char* argv[]) vertex_t u = strong_comp[c][0]; for (i = 0; i < strong_comp[c].size(); ++i) { vertex_t v = strong_comp[c][i]; - graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { - auto x = target(*ei, g); + for (const auto& edge : make_range_pair(out_edges(v, g))) { + auto x = target(edge, g); auto comp_x = comp[index_map[x]]; if (comp_x != c && mark[comp_x] != c) { mark[comp_x] = c; diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index af1d27cf..30dfdf16 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -13,6 +13,7 @@ #include #include #include "helper.hpp" +#include "range_pair.hpp" using namespace boost; @@ -102,10 +103,9 @@ main(int argc, char *argv[]) all_closeness_centralities(g, dm, cm, m); // Print the scaled closeness centrality of each vertex. - graph_traits::vertex_iterator i, end; - for(std::tie(i, end) = vertices(g); i != end; ++i) { - std::cout << std::setw(12) << std::setiosflags(std::ios::left) - << g[*i].name << get(cm, *i) << std::endl; + for(const auto& vertex : make_range_pair(vertices(g))) { + std::cout << std::setw(12) << std::setiosflags(std::ios::left) + << g[vertex].name << get(cm, vertex) << std::endl; } return 0; diff --git a/example/scc.cpp b/example/scc.cpp index f909b6f3..86c6f8cf 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -27,12 +27,11 @@ main() auto vertex_attr_map = get(vertex_attribute, g); std::string color[] = { "white", "gray", "black", "lightgray"}; - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - vertex_attr_map[*vi]["color"] = color[component[*vi]]; - vertex_attr_map[*vi]["style"] = "filled"; - if (vertex_attr_map[*vi]["color"] == "black") - vertex_attr_map[*vi]["fontcolor"] = "white"; + for (const auto& vertex : make_range_pair(vertices(g))) { + vertex_attr_map[vertex]["color"] = color[component[vertex]]; + vertex_attr_map[vertex]["style"] = "filled"; + if (vertex_attr_map[vertex]["color"] == "black") + vertex_attr_map[vertex]["fontcolor"] = "white"; } write_graphviz("figs/scc-out.dot", g); diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index d18f608b..9494bb54 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "range_pair.hpp" /* Sample Output @@ -108,13 +109,10 @@ int main(int , char* []) for (int i = 0; i < 14; ++i) add_edge(edges[i].first, edges[i].second, G); - //Creating two iterators over the vertices - graph_traits::vertex_iterator ui, ui_end; - //Creating a property_map with the degrees of the degrees of each vertex auto deg = get(vertex_degree, G); - for (std::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) - deg[*ui] = degree(*ui, G); + for (const auto& vertex : make_range_pair(vertices(G))) + deg[vertex] = degree(vertex, G); //Creating a property_map for the indices of a vertex auto index_map = get(vertex_index, G); diff --git a/example/straight_line_drawing.cpp b/example/straight_line_drawing.cpp index 0e38cd44..77644f7a 100644 --- a/example/straight_line_drawing.cpp +++ b/example/straight_line_drawing.cpp @@ -113,11 +113,10 @@ int main(int argc, char** argv) std::cout << "The straight line drawing is: " << std::endl; - graph_traits::vertex_iterator vi, vi_end; - for(std::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(const auto& vertex : make_range_pair(vertices(g))) { - coord_t coord(get(straight_line_drawing,*vi)); - std::cout << *vi << " -> (" << coord.x << ", " << coord.y << ")" + coord_t coord(get(straight_line_drawing,vertex)); + std::cout << vertex << " -> (" << coord.x << ", " << coord.y << ")" << std::endl; } diff --git a/example/subgraph.cpp b/example/subgraph.cpp index a8764dd1..d2e486f7 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -37,6 +37,7 @@ #include #include #include +#include "range_pair.hpp" int main(int,char*[]) { @@ -74,12 +75,11 @@ int main(int,char*[]) print_edges2(G0, get(vertex_index, G0), get(edge_index, G0)); std::cout << std::endl; - Graph::children_iterator ci, ci_end; int num = 1; - for (std::tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) { + for (const auto& vertex : make_range_pair(G0.children())) { std::cout << "G" << num++ << ":" << std::endl; - print_graph(*ci, get(vertex_index, *ci)); - print_edges2(*ci, get(vertex_index, *ci), get(edge_index, *ci)); + print_graph(vertex, get(vertex_index, vertex)); + print_edges2(vertex, get(vertex_index, vertex), get(edge_index, vertex)); std::cout << std::endl; } diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 46860a38..adfa61f1 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -37,10 +38,9 @@ topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, int *mark) { mark[u] = 1; // 1 means visited, 0 means not yet visited - graph_traits::adjacency_iterator vi, vi_end; - for (std::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) - if (mark[*vi] == 0) - topo_sort_dfs(g, *vi, topo_order, mark); + for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) + if (mark[vertex] == 0) + topo_sort_dfs(g, vertex, topo_order, mark); *--topo_order = u; } @@ -49,10 +49,9 @@ void topo_sort(const file_dep_graph & g, vertex_t * topo_order) { std::vectormark(num_vertices(g), 0); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - if (mark[*vi] == 0) - topo_sort_dfs(g, *vi, topo_order, &mark[0]); + for (const auto& vertex : make_range_pair(vertices(g))) + if (mark[vertex] == 0) + topo_sort_dfs(g, vertex, topo_order, &mark[0]); } @@ -79,9 +78,8 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - name_in >> name[*vi]; + for (const auto& vertex : make_range_pair(vertices(g))) + name_in >> name[vertex]; std::vector order(num_vertices(g)); topo_sort(g, &order[0] + num_vertices(g)); diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 63188355..4af9eed8 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -41,15 +42,14 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, { color[u] = gray_color; vis.discover_vertex(u, g); - graph_traits::out_edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { - if (color[target(*ei, g)] == white_color) { - vis.tree_edge(*ei, g); - dfs_v1(g, target(*ei, g), color, vis); - } else if (color[target(*ei, g)] == gray_color) - vis.back_edge(*ei, g); + for (const auto& edge : make_range_pair(out_edges(u, g))) { + if (color[target(edge, g)] == white_color) { + vis.tree_edge(edge, g); + dfs_v1(g, target(edge, g), color, vis); + } else if (color[target(edge, g)] == gray_color) + vis.back_edge(edge, g); else - vis.forward_or_cross_edge(*ei, g); + vis.forward_or_cross_edge(edge, g); } color[u] = black_color; vis.finish_vertex(u, g); @@ -59,10 +59,9 @@ template void generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector color(num_vertices(g), white_color); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - if (color[*vi] == white_color) - dfs_v1(g, *vi, &color[0], vis); + for (const auto& vertex : make_range_pair(vertices(g))) { + if (color[vertex] == white_color) + dfs_v1(g, vertex, &color[0], vis); } } @@ -139,9 +138,8 @@ main() std::vector name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); - graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) - name_in >> name[*vi]; + for (const auto& vertex : make_range_pair(vertices(g))) + name_in >> name[vertex]; std::vector order(num_vertices(g)); topo_sort(g, &order[0] + num_vertices(g)); diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 6cc85c4a..a0ecacca 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "range_pair.hpp" int main() @@ -22,9 +23,8 @@ main() graph_t G(N); auto name_map = get(vertex_name, G); char name = 'a'; - graph_traits::vertex_iterator v, v_end; - for (std::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) - name_map[*v] = name; + for (const auto& vertex : make_range_pair(vertices(G))) + name_map[vertex] = name; using E = std::pair; E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), @@ -41,8 +41,7 @@ main() print_graph(G_T, name_map); - graph_traits::edge_iterator ei, ei_end; - for (std::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) - assert(edge(target(*ei, G), source(*ei, G), G_T).second == true); + for (const auto& e : make_range_pair(edges(G))) + assert(edge(target(e, G), source(e, G), G_T).second == true); return 0; } diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 3ca41d91..176fba22 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -8,6 +8,8 @@ #include #include #include +#include "range_pair.hpp" + using namespace boost; template void @@ -15,8 +17,6 @@ undirected_graph_demo1() { const int V = 3; UndirectedGraph undigraph(V); - typename graph_traits::out_edge_iterator out, out_end; - typename graph_traits::in_edge_iterator in, in_end; auto zero = vertex(0, undigraph); auto one = vertex(1, undigraph); @@ -26,11 +26,11 @@ undirected_graph_demo1() add_edge(one, two, undigraph); std::cout << "out_edges(0):"; - for (std::tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out) - std::cout << ' ' << *out; + for (const auto& edge : make_range_pair(out_edges(zero, undigraph))) + std::cout << ' ' << edge; std::cout << std::endl << "in_edges(0):"; - for (std::tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in) - std::cout << ' ' << *in; + for (const auto& edge : make_range_pair(in_edges(zero, undigraph))) + std::cout << ' ' << edge; std::cout << std::endl; } @@ -89,11 +89,10 @@ undirected_graph_demo2() std::cout << "weight[(v,u)] = " << get(weight, e2) << std::endl; std::cout << "the edges incident to v: "; - typename boost::graph_traits::out_edge_iterator e, e_end; auto s = vertex(0, undigraph); - for (std::tie(e, e_end) = out_edges(s, undigraph); e != e_end; ++e) - std::cout << "(" << source(*e, undigraph) - << "," << target(*e, undigraph) << ")" << std::endl; + for (const auto& edge : make_range_pair(out_edges(s, undigraph))) + std::cout << "(" << source(edge, undigraph) + << "," << target(edge, undigraph) << ")" << std::endl; } diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index b1dc34d9..d7d0f531 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -144,8 +145,8 @@ main() std::cout << "vertices(g) = "; boost::graph_traits::vertex_iterator vi; - for (vi = vertices(g).first; vi != vertices(g).second; ++vi) - std::cout << id[*vi] << " "; + for (const auto& vertex : make_range_pair(vertices(g))) + std::cout << id[vertex] << " "; std::cout << std::endl; /* Use the STL for_each algorithm to "exercise" all From 2c2fe2cbc89194fb6a6340033655f080989ae2e5 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 10 May 2017 16:13:43 +0200 Subject: [PATCH 17/28] examples: C++11: More range-based for loops. --- example/adj_list_ra_edgelist.cpp | 1 - example/astar-cities.cpp | 5 ++--- example/bron_kerbosch_print_cliques.cpp | 5 ++--- example/canonical_ordering.cpp | 5 ++--- example/connected-components.cpp | 3 +-- example/dfs.cpp | 3 +-- example/dijkstra-example-listS.cpp | 1 - example/file_dependencies.cpp | 11 +++++------ example/king_ordering.cpp | 5 ++--- example/kruskal-example.cpp | 7 +++---- example/kuratowski_subgraph.cpp | 5 ++--- example/loops_dfs.cpp | 8 ++++---- example/matching_example.cpp | 4 ++-- example/min_max_paths.cpp | 1 - example/modify_graph.cpp | 1 - example/parallel-compile-time.cpp | 7 ++----- example/quick_tour.cpp | 2 -- example/sloan_ordering.cpp | 10 ++++------ example/tiernan_print_cycles.cpp | 5 ++--- example/topo-sort-with-leda.cpp | 5 ++--- example/vertex_basics.cpp | 1 - 21 files changed, 36 insertions(+), 59 deletions(-) diff --git a/example/adj_list_ra_edgelist.cpp b/example/adj_list_ra_edgelist.cpp index 13b5e124..a75a1ebd 100644 --- a/example/adj_list_ra_edgelist.cpp +++ b/example/adj_list_ra_edgelist.cpp @@ -24,7 +24,6 @@ main() const std::size_t m = sizeof(edge_array) / sizeof(E); Graph g(edge_array, edge_array + m, n); - graph_traits::edge_iterator edge_iterator; for (std::size_t i = 0; i < m; ++i) { const graph_traits::edge_iterator e = edges(g).first + i; std::cout << *e << " "; diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 20c7af0c..5340c343 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -208,10 +208,9 @@ int main(int argc, char **argv) } std::cout << "Shortest path from " << name[start] << " to " << name[goal] << ": "; - auto spi = shortest_path.begin(); std::cout << name[start]; - for(++spi; spi != shortest_path.end(); ++spi) - std::cout << " -> " << name[*spi]; + for(const auto& sp : shortest_path) + std::cout << " -> " << name[sp]; std::cout << std::endl << "Total travel time: " << d[goal] << std::endl; return 0; } diff --git a/example/bron_kerbosch_print_cliques.cpp b/example/bron_kerbosch_print_cliques.cpp index 72744727..6aeae032 100644 --- a/example/bron_kerbosch_print_cliques.cpp +++ b/example/bron_kerbosch_print_cliques.cpp @@ -27,9 +27,8 @@ struct clique_printer void clique(const Clique& c, const Graph& g) { // Iterate over the clique and print each vertex within it. - typename Clique::const_iterator i, end = c.end(); - for(i = c.begin(); i != end; ++i) { - os << g[*i].name << " "; + for(const auto& vertex : c) { + os << g[vertex].name << " "; } os << std::endl; } diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index 4821602f..70ed3935 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -76,10 +76,9 @@ int main(int argc, char** argv) embedding.begin(), get(vertex_index, g)), std::back_inserter(ordering)); - auto oi_end = ordering.end(); std::cout << "The planar canonical ordering is: "; - for(auto oi = ordering.begin(); oi != oi_end; ++oi) - std::cout << *oi << " "; + for(const auto& o : ordering) + std::cout << o << " "; std::cout << std::endl; return 0; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 0160d102..5601ccde 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -29,9 +29,8 @@ main() (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); std::cout << std::endl; - std::vector::iterator i; std::cout << "Total number of components: " << num << std::endl; - for (i = c.begin(); i != c.end(); ++i) + for (auto i = c.begin(); i != c.end(); ++i) std::cout << "Vertex " << i - c.begin() << " is in component " << *i << std::endl; std::cout << std::endl; diff --git a/example/dfs.cpp b/example/dfs.cpp index d08faafb..a77b42ed 100644 --- a/example/dfs.cpp +++ b/example/dfs.cpp @@ -115,8 +115,7 @@ main(int , char* []) std::make_pair(stamp_times(&d[0], t, on_discover_vertex()), stamp_times(&f[0], t, on_finish_vertex()))))); - std::vector::iterator i, j; - for (i = d.begin(), j = f.begin(); i != d.end(); ++i, ++j) + for (auto i = d.begin(), j = f.begin(); i != d.end(); ++i, ++j) std::cout << *i << " " << *j << std::endl; return 0; diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 065b98e8..c6f1c352 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -36,7 +36,6 @@ main(int, char *[]) }; int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 }; int num_arcs = sizeof(edge_array) / sizeof(Edge); - graph_traits::vertex_iterator i, iend; graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes); auto weightmap = get(edge_weight, g); diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index acab35dd..a04e814c 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -120,21 +120,20 @@ int main(int,char*[]) topological_sort(g, std::front_inserter(make_order)); std::cout << "make ordering: "; - for (i = make_order.begin(); - i != make_order.end(); ++i) - std::cout << name[*i] << " "; + for (const auto& o : make_order) + std::cout << name[o] << " "; std::cout << std::endl << std::endl; // Parallel compilation ordering std::vector time(N, 0); - for (i = make_order.begin(); i != make_order.end(); ++i) { + for (const auto& vertex : make_order) { // Walk through the in_edges an calculate the maximum time. - if (in_degree (*i, g) > 0) { + if (in_degree (vertex, g) > 0) { int maxdist=0; // Through the order from topological sort, we are sure that every // time we are using here is already initialized. - for (const auto& edge : make_range_pair(in_edges(*i, g))) + for (const auto& edge : make_range_pair(in_edges(vertex, g))) maxdist=(std::max)(time[source(edge, g)], maxdist); time[*i]=maxdist+1; } diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index b17c03b8..17028e6c 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -76,9 +76,8 @@ int main(int , char* []) get(vertex_degree, G), get(vertex_index, G)); std::cout << "King ordering starting at: " << s << std::endl; std::cout << " "; - for (auto i = inv_perm.begin(); - i != inv_perm.end(); ++i) - std::cout << index_map[*i] << " "; + for (const auto& vertex : inv_perm) + std::cout << index_map[vertex] << " "; std::cout << std::endl; for (size_type c = 0; c != inv_perm.size(); ++c) diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 28acfb85..060dfb0f 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -43,10 +43,9 @@ main() kruskal_minimum_spanning_tree(g, std::back_inserter(spanning_tree)); std::cout << "Print the edges in the MST:" << std::endl; - for (auto ei = spanning_tree.begin(); - ei != spanning_tree.end(); ++ei) { - std::cout << source(*ei, g) << " <--> " << target(*ei, g) - << " with weight of " << weight[*ei] + for (const auto& edge : spanning_tree) { + std::cout << source(edge, g) << " <--> " << target(edge, g) + << " with weight of " << weight[edge] << std::endl; } diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index 91b0e853..ebc0fa58 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -70,10 +70,9 @@ int main(int argc, char** argv) std::cout << "Input graph is not planar" << std::endl; std::cout << "Edges in the Kuratowski subgraph: "; - auto ki_end = kuratowski_edges.end(); - for(auto ki = kuratowski_edges.begin(); ki != ki_end; ++ki) + for(const auto& k : kuratowski_edges) { - std::cout << *ki << " "; + std::cout << k << " "; } std::cout << std::endl; diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 8d7e4cb9..87dceefb 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -131,11 +131,11 @@ main(int argc, char *argv[]) auto vattr_map = get(vertex_attribute, g); auto eattr_map = get(edge_attribute, g); - for (auto i = loops.begin(); i != loops.end(); ++i) { + for (const auto& loop : loops) { std::vector in_loop(num_vertices(g), false); - for (auto j = (*i).begin(); j != (*i).end(); ++j) { - vattr_map[*j]["color"] = "gray"; - in_loop[*j] = true; + for (const auto& vertex : loop) { + vattr_map[vertex]["color"] = "gray"; + in_loop[vertex] = true; } for (const auto& edge : make_range_pair(edges(g))) if (in_loop[source(edge, g)] && in_loop[target(edge, g)]) diff --git a/example/matching_example.cpp b/example/matching_example.cpp index a84fb878..e38984ef 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -102,8 +102,8 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for (auto itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) - std::cout << *itr << std::endl; + for (const auto& str : ascii_graph) + std::cout << str << std::endl; std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) << std::endl; diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index d26ebea3..f7182a56 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -87,7 +87,6 @@ main(int , char* []) #endif std::cout << "distances from start vertex:" << std::endl; - graph_traits::vertex_iterator vi, vend; for(const auto& vertex : make_range_pair(vertices(G))) std::cout << "distance(" << name[vertex] << ") = " << d[vertex] << std::endl; std::cout << std::endl; diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index e9f2f4ca..5a7faefc 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -182,7 +182,6 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); for (const auto & vertex : make_range_pair(vertices(g))) { - typename GraphTraits::adjacency_iterator ai, ai_end; for (const auto& adjacent_vertex : make_range_pair(adjacent_vertices(vertex, g))) assert(adjacent_vertex != vertex); } diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 47872157..80f30748 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -177,11 +177,8 @@ main() else distance_map[vertex] = 0; - std::vector::iterator ui; - for (ui = topo_order.begin(); ui != topo_order.end(); ++ui) { - vertex_t - u = * - ui; + + for (const auto& u : topo_order) { for (const auto& vertex : make_range_pair(adjacent_vertices(u, g))) if (distance_map[vertex] < distance_map[u] + compile_cost_map[vertex]) distance_map[vertex] = distance_map[u] + compile_cost_map[vertex]; diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 588b1f41..2aea2df6 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -100,8 +100,6 @@ int main(int,char*[]) trans_delay = get(edge_weight, g); std::cout << "vertices(g) = "; - using vertex_iter = graph_traits::vertex_iterator; - std::pair vp; for (const auto& vertex : make_range_pair(vertices(g))) std::cout << name[get(vertex_id, vertex)] << " "; std::cout << std::endl; diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index 9494bb54..8c1bd610 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -152,9 +152,8 @@ int main(int , char* []) std::cout << "Sloan ordering starting at: " << s << std::endl; std::cout << " "; - for (auto i = sloan_order.begin(); - i != sloan_order.end(); ++i) - std::cout << index_map[*i] << " "; + for (const auto& vertex : sloan_order) + std::cout << index_map[vertex] << " "; std::cout << std::endl; for (size_type c = 0; c != sloan_order.size(); ++c) @@ -192,9 +191,8 @@ int main(int , char* []) std::cout << std::endl << "Sloan ordering without a start-vertex:" << std::endl; std::cout << " "; - for (auto i=sloan_order.begin(); - i != sloan_order.end(); ++i) - std::cout << index_map[*i] << " "; + for (const auto& vertex : sloan_order) + std::cout << index_map[vertex] << " "; std::cout << std::endl; for (size_type c = 0; c != sloan_order.size(); ++c) diff --git a/example/tiernan_print_cycles.cpp b/example/tiernan_print_cycles.cpp index b8b5e772..0e08e9d6 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -33,9 +33,8 @@ struct cycle_printer auto indices = get(vertex_index, g); // Iterate over path printing each vertex that forms the cycle. - typename Path::const_iterator i, end = p.end(); - for(i = p.begin(); i != end; ++i) { - os << get(indices, *i) << " "; + for(const auto& vertex : p) { + os << get(indices, vertex) << " "; } os << std::endl; } diff --git a/example/topo-sort-with-leda.cpp b/example/topo-sort-with-leda.cpp index 11edac49..11a99110 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -46,9 +46,8 @@ main() std::reverse(topo_order.begin(), topo_order.end()); int n = 1; - for (auto i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) - std::cout << n << ": " << leda_g[*i] << std::endl; + for (const auto& vertex : topo_order) + std::cout << n << ": " << leda_g[vertex] << std::endl; return EXIT_SUCCESS; } diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index d7d0f531..c5671210 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -144,7 +144,6 @@ main() id = get(vertex_index, g); std::cout << "vertices(g) = "; - boost::graph_traits::vertex_iterator vi; for (const auto& vertex : make_range_pair(vertices(g))) std::cout << id[vertex] << " "; std::cout << std::endl; From edcf010e7825b8844e9f618741ce9ec22dfbc8e9 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 10 May 2017 16:57:46 +0200 Subject: [PATCH 18/28] examples: C++17: Use structured bindings instead of std::tie(). So we can use auto. --- example/accum-compile-times.cpp | 7 +------ example/astar-cities.cpp | 4 +--- example/bfs-name-printer.cpp | 5 +---- example/boost_web_graph.cpp | 6 ++---- example/cycle-file-dep.cpp | 3 +-- example/cycle-file-dep2.cpp | 3 +-- example/eccentricity.cpp | 3 +-- example/edge-connectivity.cpp | 11 +++++------ example/edge-function.cpp | 13 +++++-------- example/edge_iterator_constructor.cpp | 3 +-- example/family_tree.cpp | 3 +-- example/file_dependencies.cpp | 3 +-- example/graph-property-iter-eg.cpp | 2 +- example/graph.cpp | 5 ++--- example/helper.hpp | 5 +---- example/incremental_components.cpp | 5 +---- example/kevin-bacon.cpp | 9 +++------ example/knights_tour.cpp | 14 +++++--------- example/kruskal-example.cpp | 3 +-- example/min_max_paths.cpp | 3 +-- example/modify_graph.cpp | 25 +++++++++++-------------- example/ordered_out_edges.cpp | 9 ++------- example/parallel-compile-time.cpp | 7 ++----- example/prim-example.cpp | 3 +-- example/print-adjacent-vertices.cpp | 3 +-- example/print-in-edges.cpp | 3 +-- example/print-out-edges.cpp | 3 +-- example/quick-tour.cpp | 14 +++++++------- example/quick_tour.cpp | 3 +-- example/read_write_dimacs-eg.cpp | 4 +--- example/tiernan_girth_circumference.cpp | 3 +-- example/topo-sort-file-dep.cpp | 3 +-- example/topo-sort-file-dep2.cpp | 3 +-- example/undirected_adjacency_list.cpp | 12 ++++-------- 34 files changed, 71 insertions(+), 134 deletions(-) diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 34376263..5dc88c13 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -44,9 +44,6 @@ using file_dep_graph2 = adjacency_list>; -using vertex_t = graph_traits::vertex_descriptor; -using edge_t = graph_traits::edge_descriptor; - int main() { @@ -79,9 +76,7 @@ main() compile_cost_in >> compile_cost_map[vertex]; } - graph_property_iter_range < file_dep_graph2, - vertex_compile_cost_t >::iterator ci, ci_end; - std::tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost); + const auto [ci, ci_end] = get_property_iter_range(g, vertex_compile_cost); std::cout << "total (sequential) compile time: " << std::accumulate(ci, ci_end, 0.0) << std::endl; diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 5340c343..ff4be6f3 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -116,7 +116,6 @@ int main(int argc, char **argv) property>; using WeightMap = property_map::type; using vertex = mygraph_t::vertex_descriptor; - using edge_descriptor = mygraph_t::edge_descriptor; using edge = std::pair; // specify data @@ -161,8 +160,7 @@ int main(int argc, char **argv) mygraph_t g(N); auto weightmap = get(edge_weight, g); for(std::size_t j = 0; j < num_edges; ++j) { - edge_descriptor e; bool inserted; - std::tie(e, inserted) = add_edge(edge_array[j].first, + const auto [e, inserted] = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index 7c98b816..a70e8f19 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -28,10 +28,7 @@ build_router_network(Graph & g, VertexNameMap name_map, auto e = add_vertex(g); name_map[e] = 'e'; - typename graph_traits::edge_descriptor ed; - bool inserted; - - std::tie(ed, inserted) = add_edge(a, b, g); + auto [ed, inserted] = add_edge(a, b, g); delay_map[ed] = 1.2; std::tie(ed, inserted) = add_edge(a, d, g); delay_map[ed] = 4.5; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index fde152c7..27697a72 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -109,13 +109,11 @@ main() std::list line_toks; boost::stringtok(line_toks, line, "|"); - NameVertexMap::iterator pos; - bool inserted; Vertex u, v; auto i = line_toks.begin(); - std::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); + auto [pos, inserted] = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { u = add_vertex(g); put(node_name, u, *i); @@ -190,7 +188,7 @@ main() // Add all the search tree edges into a new graph Graph search_tree(num_vertices(g)); - std::tie(vi, vi_end) = vertices(g); + auto [vi, vi_end] = vertices(g); ++vi; for (; vi != vi_end; ++vi) add_edge(parent[*vi], *vi, search_tree); diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index 9d13e74e..97d74d7e 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -72,8 +72,7 @@ main() // VC++ has trouble with the edge iterator constructor file_dep_graph g(n_vertices); while (input_begin != input_end) { - size_type i, j; - std::tie(i, j) = *input_begin++; + const auto [i, j] = *input_begin++; add_edge(i, j, g); } #else diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index cde0c3f4..bf002cc6 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -129,8 +129,7 @@ main() // VC++ has trouble with the edge iterator constructor file_dep_graph g(n_vertices); while (input_begin != input_end) { - size_type i, j; - std::tie(i, j) = *input_begin++; + const auto [i, j] = *input_begin++; add_edge(i, j, g); } #else diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index a1788741..0a44771d 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -70,10 +70,9 @@ main(int argc, char *argv[]) // Compute the eccentricities for graph - this computation returns // both the radius and diameter as well. - int r, d; EccentricityContainer eccs(num_vertices(g)); EccentricityMap em(eccs, g); - std::tie(r, d) = all_eccentricities(g, dm, em); + const auto [r, d] = all_eccentricities(g, dm, em); // Print the closeness centrality of each vertex. for(const auto& vertex : make_range_pair(vertices(g))) { diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 1cc9ace5..7f87fc95 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -67,10 +67,9 @@ namespace boost property < edge_residual_capacity_t, degree_size_type, property>>>; - vertex_descriptor u, v, p, k; - edge_descriptor e1, e2; + vertex_descriptor u, v, k; bool inserted; - degree_size_type delta, alpha_star, alpha_S_k; + degree_size_type alpha_star, alpha_S_k; std::set S, neighbor_S; std::vector S_star, nonneighbor_S; std::vector color(num_vertices(g)); @@ -83,15 +82,15 @@ namespace boost for (const auto& edge : make_range_pair(edges(g))) { u = source(edge, g), v = target(edge, g); - std::tie(e1, inserted) = add_edge(u, v, flow_g); + const auto [e1, inserted1] = add_edge(u, v, flow_g); cap[e1] = 1; - std::tie(e2, inserted) = add_edge(v, u, flow_g); + const auto [e2, inserted2] = add_edge(v, u, flow_g); cap[e2] = 1; rev_edge[e1] = e2; rev_edge[e2] = e1; } - std::tie(p, delta) = min_degree_vertex(g); + const auto [p, delta] = min_degree_vertex(g); S_star.emplace_back(p); alpha_star = delta; S.insert(p); diff --git a/example/edge-function.cpp b/example/edge-function.cpp index 7c201e06..8675b5df 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -106,8 +106,7 @@ main() // Get vertex name property map from the graph auto name = get(vertex_name, g); // Get iterators for the vertex set - graph_traits::vertex_iterator i, end; - std::tie(i, end) = vertices(g); + const auto [i, end] = vertices(g); // Find yow.h using name_map_t = property_map::type; name_equals_t predicate1("yow.h", name); @@ -119,18 +118,16 @@ main() name_equals_t predicate3("bar.o", name); bar = *std::find_if(i, end, predicate3); - graph_traits::edge_descriptor e1, e2; - bool exists; // Get the edge connecting yow.h to zag.o - std::tie(e1, exists) = edge(yow, zag, g); - assert(exists == true); + const auto [e1, exists1] = edge(yow, zag, g); + assert(exists1 == true); assert(source(e1, g) == yow); assert(target(e1, g) == zag); // Discover that there is no edge connecting zag.o to bar.o - std::tie(e2, exists) = edge(zag, bar, g); - assert(exists == false); + const auto [e2, exists2] = edge(zag, bar, g); + assert(exists2 == false); assert(num_vertices(g) == 15); assert(num_edges(g) == 19); diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index d133f26b..8557bffd 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -106,8 +106,7 @@ main() // VC++ can't handle the iterator constructor IteratorConstructibleGraph G(size_V); while (edge_iter != end) { - int i, j; - std::tie(i, j) = *edge_iter++; + const auto [i, j] = *edge_iter++; boost::add_edge(i, j, G); } #else diff --git a/example/family_tree.cpp b/example/family_tree.cpp index 9c0cff5c..1e49faf1 100644 --- a/example/family_tree.cpp +++ b/example/family_tree.cpp @@ -31,12 +31,11 @@ main() add_edge(Rick, Margaret, g); add_edge(John, Benjamin, g); - graph_traits>::adjacency_iterator ai, a_end; auto index_map = get(vertex_index, g); for (const auto& vertex : make_range_pair(vertices(g))) { std::cout << name[get(index_map, vertex)]; - std::tie(ai, a_end) = adjacent_vertices(vertex, g); + auto [ai, a_end] = adjacent_vertices(vertex, g); if (ai == a_end) std::cout << " has no children"; else diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index a04e814c..0d09f522 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -103,8 +103,7 @@ int main(int,char*[]) // VC++ can't handle the iterator constructor Graph g(N); for (std::size_t j = 0; j < nedges; ++j) { - graph_traits::edge_descriptor e; bool inserted; - std::tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g); + const auto [e, inserted] = add_edge(used_by[j].first, used_by[j].second, g); } #else Graph g(used_by, used_by + nedges, N); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index c5f7c817..97b8ef6f 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -28,7 +28,7 @@ main() ++i; } - std::tie(v, v_end) = get_property_iter_range(g, vertex_name); + auto [v, v_end] = get_property_iter_range(g, vertex_name); std::copy(v, v_end, std::ostream_iterator (std::cout, " ")); std::cout << std::endl; return 0; diff --git a/example/graph.cpp b/example/graph.cpp index f3b96d39..165cf12a 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -44,10 +44,9 @@ std::size_t myrand(std::size_t N) { template bool check_edge(Graph& g, std::size_t a, std::size_t b) { - typename Graph::adjacency_iterator vi, viend, found; - std::tie(vi, viend) = adjacent_vertices(vertex(a,g), g); + auto [vi, viend] = adjacent_vertices(vertex(a,g), g); - found = find(vi, viend, vertex(b, g)); + auto found = find(vi, viend, vertex(b, g)); if ( found == viend ) return false; diff --git a/example/helper.hpp b/example/helper.hpp index 192e5f6b..3bacfc6b 100644 --- a/example/helper.hpp +++ b/example/helper.hpp @@ -19,12 +19,9 @@ typename boost::graph_traits::vertex_descriptor add_named_vertex(Graph& g, NameMap nm, const std::string& name, VertexMap& vm) { using Vertex = typename boost::graph_traits::vertex_descriptor; - using Iterator = typename VertexMap::iterator; Vertex v; - Iterator iter; - bool inserted; - std::tie(iter, inserted) = vm.insert(make_pair(name, Vertex())); + auto [iter, inserted] = vm.insert(make_pair(name, Vertex())); if(inserted) { // The name was unique so we need to add a vertex to the graph v = add_vertex(g); diff --git a/example/incremental_components.cpp b/example/incremental_components.cpp index 32262750..fa04242c 100644 --- a/example/incremental_components.cpp +++ b/example/incremental_components.cpp @@ -67,10 +67,7 @@ int main(int argc, char* argv[]) initialize_incremental_components(graph, ds); incremental_components(graph, ds); - graph_traits::edge_descriptor edge; - bool flag; - - std::tie(edge, flag) = add_edge(0, 1, graph); + auto [edge, flag] = add_edge(0, 1, graph); ds.union_set(0,1); std::tie(edge, flag) = add_edge(1, 4, graph); diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index e1339d7e..b2551234 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -71,10 +71,8 @@ main() tokenizer <> line_toks(line, sep); tokenizer <>::iterator i = line_toks.begin(); std::string actors_name = *i++; - NameVertexMap::iterator pos; - bool inserted; Vertex u, v; - std::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex())); + auto [pos, inserted] = actors.insert(std::make_pair(actors_name, Vertex())); if (inserted) { u = add_vertex(g); actor_name[u] = actors_name; @@ -92,9 +90,8 @@ main() } else v = pos->second; - graph_traits::edge_descriptor e; - std::tie(e, inserted) = add_edge(u, v, g); - if (inserted) + auto [e, insertede] = add_edge(u, v, g); + if (insertede) connecting_movie[e] = movie_name; } diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 14528ef1..3f5d21b9 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -160,12 +160,10 @@ template using Vertex = typename graph_traits::vertex_descriptor; using P = std::pair; std::stack

S; - int time_stamp = 0; - S.push(std::make_pair(time_stamp, src)); + S.push(std::make_pair(0, src)); while (!S.empty()) { - Vertex x; - std::tie(time_stamp, x) = S.top(); + auto [time_stamp, x] = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) @@ -181,7 +179,7 @@ template if (deadend) { put(time_map, x, -1); S.pop(); - std::tie(time_stamp, x) = S.top(); + auto [time_stamp, x] = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); @@ -211,12 +209,10 @@ template using Vertex = typename graph_traits::vertex_descriptor; using P = std::pair; std::stack

S; - int time_stamp = 0; - S.push(std::make_pair(time_stamp, src)); + S.push(std::make_pair(0, src)); while (!S.empty()) { - Vertex x; - std::tie(time_stamp, x) = S.top(); + auto [time_stamp, x] = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 060dfb0f..f30e605b 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -30,8 +30,7 @@ main() Graph g(num_nodes); auto = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { - Edge e; bool inserted; - std::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + auto [e, inserted] = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } #else diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index f7182a56..3f58565a 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -60,8 +60,7 @@ main(int , char* []) Graph G(num_nodes); auto weightmap = get(edge_weight, G); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { - graph_traits::edge_descriptor e; bool inserted; - std::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); + auto [e, inserted] = add_edge(edges[j].first, edges[j].second, G); weightmap[e] = weights[j]; } #else diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 5a7faefc..522bbb7b 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -84,7 +84,7 @@ void modify_demo(MutableGraph& g) u = add_vertex(g); v = add_vertex(g); - std::tie(e, added) = add_edge(u, v, g); + auto [e, added] = add_edge(u, v, g); assert(num_edges(g) == m + 2); assert(added == true); // edge should have been added @@ -99,15 +99,14 @@ void modify_demo(MutableGraph& g) remove_edge(u, v, g); assert(num_edges(g) == m + 1); - bool exists; - std::tie(e, exists) = edge(u, v, g); + auto [e, exists] = edge(u, v, g); assert(exists == false); assert(out_degree(u, g) == 0); assert(in_degree(v, g) == 0); } { e = *edges(g).first; - std::tie(u, v) = incident(e, g); + auto [u, v] = incident(e, g); remove_edge(e, g); @@ -118,8 +117,7 @@ void modify_demo(MutableGraph& g) { add_edge(u, v, g); - typename GraphTraits::out_edge_iterator iter, iter_end; - std::tie(iter, iter_end) = out_edges(u, g); + auto [iter, iter_end] = out_edges(u, g); remove_edge(iter, g); @@ -129,13 +127,12 @@ void modify_demo(MutableGraph& g) } { w = add_vertex(g); - std::tie(e1, added) = add_edge(u, v, g); - std::tie(e2, added) = add_edge(v, w, g); + auto [e1, added1] = add_edge(u, v, g); + auto [e2, added2] = add_edge(v, w, g); name_map[e1] = "I-5"; name_map[e2] = "Route 66"; - typename GraphTraits::out_edge_iterator iter, iter_end; - std::tie(iter, iter_end) = out_edges(u, g); + auto [iter, iter_end] = out_edges(u, g); remove_edge_if(name_equals("Route 66", name_map), g); @@ -150,8 +147,8 @@ void modify_demo(MutableGraph& g) assert(in_degree(w, g) == 0); } { - std::tie(e1, added) = add_edge(u, v, g); - std::tie(e2, added) = add_edge(u, w, g); + auto [e1, added1] = add_edge(u, v, g); + auto [e2, added2] = add_edge(u, w, g); name_map[e1] = "foo"; name_map[e2] = "foo"; @@ -161,8 +158,8 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); } { - std::tie(e1, added) = add_edge(u, v, g); - std::tie(e2, added) = add_edge(w, v, g); + auto [e1, added1] = add_edge(u, v, g); + auto [e2, added2] = add_edge(w, v, g); name_map[e1] = "bar"; name_map[e2] = "bar"; diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index bf5511e2..c1e01574 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -102,19 +102,14 @@ main() } std::cout << std::endl; - bool found; - using Traits = graph_traits; - Traits::edge_descriptor e; - Traits::out_edge_iterator e_first, e_last; - - std::tie(e, found) = edge(0, 1, g); + auto [e, found] = edge(0, 1, g); if (found) std::cout << "name(0,1) = " << name[e] << std::endl; else std::cout << "not found" << std::endl; std::cout << std::endl; - std::tie(e_first, e_last) = edge_range(0, 1, g); + auto [e_first, e_last] = edge_range(0, 1, g); while (e_first != e_last) std::cout << "name(0,1) = " << name[*e_first++] << std::endl; #endif diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 80f30748..9ddb0353 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -130,8 +130,7 @@ main() for (std::size_t v = 0; v < n_vertices; ++v) id2vertex.emplace_back(add_vertex(g)); while (input_begin != input_end) { - size_type i, j; - std::tie(i, j) = *input_begin++; + auto [i, j] = *input_begin++; add_edge(id2vertex[i], id2vertex[j], g); } #else @@ -184,9 +183,7 @@ main() distance_map[vertex] = distance_map[u] + compile_cost_map[vertex]; } - graph_property_iter_range < file_dep_graph2, - vertex_distance_t >::iterator ci, ci_end; - std::tie(ci, ci_end) = get_property_iter_range(g, vertex_distance); + auto [ci, ci_end] = get_property_iter_range(g, vertex_distance); std::cout << "total (parallel) compile time: " << *std::max_element(ci, ci_end) << std::endl; diff --git a/example/prim-example.cpp b/example/prim-example.cpp index 006e63e8..4f538269 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -26,8 +26,7 @@ main() Graph g(num_nodes); auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { - graph_traits::edge_descriptor e; bool inserted; - std::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); + auto [e, inserted] = add_edge(edges[j].first, edges[j].second, g); weightmap[e] = weights[j]; } #else diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 4a3ceb85..715dcf5f 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -100,8 +100,7 @@ main() get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits::vertex_iterator i, end; - std::tie(i, end) = vertices(g); + auto [i, end] = vertices(g); i = std::find_if(i, end, name_equals("dax.h", get(vertex_name, g))); output_adjacent_vertices(std::cout, *i, g, get(vertex_name, g)); diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index 986996b4..2cd1c7d4 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -100,8 +100,7 @@ main() get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits::vertex_iterator i, end; - std::tie(i, end) = vertices(g); + auto [i, end] = vertices(g); i = std::find_if(i, end, name_equals("libzigzag.a", get(vertex_name, g))); output_in_edges(std::cout, g, *i, get(vertex_name, g)); assert(num_vertices(g) == 15); diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index 2a488178..e1f06ad8 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -99,8 +99,7 @@ main() get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits::vertex_iterator i, end; - std::tie(i, end) = vertices(g); + auto [i, end] = vertices(g); using name_map_t = property_map::type; name_equals_t predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 16d13752..2a9fbc5f 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -70,19 +70,19 @@ build_router_network(Graph & g, VertexNameMap name_map, typename graph_traits::edge_descriptor ed; bool inserted; - std::tie(ed, inserted) = add_edge(a, b, g); + auto [ed, inserted] = add_edge(a, b, g); delay_map[ed] = 1.2; - std::tie(ed, inserted) = add_edge(a, d, g); + auto [ed, inserted] = add_edge(a, d, g); delay_map[ed] = 4.5; - std::tie(ed, inserted) = add_edge(b, d, g); + auto [ed, inserted] = add_edge(b, d, g); delay_map[ed] = 1.8; - std::tie(ed, inserted) = add_edge(c, a, g); + auto [ed, inserted] = add_edge(c, a, g); delay_map[ed] = 2.6; - std::tie(ed, inserted) = add_edge(c, e, g); + auto [ed, inserted] = add_edge(c, e, g); delay_map[ed] = 5.2; - std::tie(ed, inserted) = add_edge(d, c, g); + auto [ed, inserted] = add_edge(d, c, g); delay_map[ed] = 0.4; - std::tie(ed, inserted) = add_edge(d, e, g); + auto [ed, inserted] = add_edge(d, e, g); delay_map[ed] = 3.3; } diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index 2aea2df6..a4005449 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -85,8 +85,7 @@ int main(int,char*[]) Graph g(num_vertices); auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { - graph_traits::edge_descriptor e; bool inserted; - std::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + auto [e, inserted] = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = transmission_delay[j]; } #else diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 541005f3..8994a401 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -88,9 +88,7 @@ int main() //we take the source node and check for each outgoing edge e which has a target(p) if we can augment that path for(const auto& from_source : make_range_pair(out_edges(s, g))){ auto v = target(from_source, g); - edge_descriptor to_sink; - bool is_there; - std::tie(to_sink, is_there) = edge(v, t, g); + auto [to_sink, is_there] = edge(v, t, g); if( is_there ){ if( get(capacity, to_sink) > get(capacity, from_source) ){ auto to_augment = get(capacity, from_source); diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index ff52b0c3..f33d5cad 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -27,8 +27,7 @@ main(int argc, char *argv[]) read_graph(g, std::cin); // Compute the girth and circumference simulataneously - size_t girth, circ; - std::tie(girth, circ) = tiernan_girth_and_circumference(g); + auto [girth, circ] = tiernan_girth_and_circumference(g); // Print the result std::cout << "girth: " << girth << std::endl; diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index adfa61f1..2544523c 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -68,8 +68,7 @@ main() // VC++ can't handle the iterator constructor file_dep_graph g(n_vertices); while (input_begin != input_end) { - size_type i, j; - std::tie(i, j) = *input_begin++; + auto [i, j] = *input_begin++; add_edge(i, j, g); } #else diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 4af9eed8..616d5e4e 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -128,8 +128,7 @@ main() // VC++ can't handle the iterator constructor file_dep_graph g(n_vertices); while (input_begin != input_end) { - size_type i, j; - std::tie(i, j) = *input_begin++; + auto [i, j] = *input_begin++; add_edge(i, j, g); } #else diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 176fba22..3cfa9beb 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -41,15 +41,13 @@ directed_graph_demo() DirectedGraph digraph(V); using Weight = typename DirectedGraph::edge_property_type; auto weight = get(edge_weight, digraph); - typename graph_traits::edge_descriptor e1, e2; - bool found; auto u = vertex(0, digraph); auto v = vertex(1, digraph); add_edge(u, v, Weight(1.2), digraph); add_edge(v, u, Weight(2.4), digraph); - std::tie(e1, found) = edge(u, v, digraph); - std::tie(e2, found) = edge(v, u, digraph); + auto [e1, found1] = edge(u, v, digraph); + auto [e2, found2] = edge(v, u, digraph); std::cout << "in a directed graph is "; #ifdef __GNUC__ // no boolalpha @@ -70,14 +68,12 @@ undirected_graph_demo2() using Weight = typename UndirectedGraph::edge_property_type; typename property_map::type weight = get(edge_weight, undigraph); - typename graph_traits::edge_descriptor e1, e2; - bool found; auto u = vertex(0, undigraph); auto v = vertex(1, undigraph); add_edge(u, v, Weight(3.1), undigraph); - std::tie(e1, found) = edge(u, v, undigraph); - std::tie(e2, found) = edge(v, u, undigraph); + auto [e1, found1] = edge(u, v, undigraph); + auto [e2, found2] = edge(v, u, undigraph); std::cout << "in an undirected graph is "; #ifdef __GNUC__ std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl; From 46ecc8e706f3b3967abd8d9c59cfa2aa716895ee Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 10 May 2017 21:51:51 +0200 Subject: [PATCH 19/28] examples: C++11: More use of auto. --- example/adj_list_ra_edgelist.cpp | 2 +- example/astar_maze.cpp | 2 +- example/boost_web_graph.cpp | 6 +++--- example/cycle_ratio_example.cpp | 5 ++--- example/edge-function.cpp | 10 ++++------ example/edge_coloring.cpp | 2 +- example/edge_property.cpp | 3 +-- example/exterior_properties.cpp | 2 +- example/fr_layout.cpp | 2 +- example/girth.cpp | 3 +-- example/graph-assoc-types.cpp | 14 +++++--------- example/grid_graph_example.cpp | 2 +- example/helper.hpp | 17 ++++++++--------- example/interior_property_map.cpp | 3 +-- example/isomorphism.cpp | 3 +-- example/kevin-bacon.cpp | 6 +++--- example/king_ordering.cpp | 2 +- example/last-mod-time.cpp | 3 +-- example/loops_dfs.cpp | 5 ++--- example/max_flow.cpp | 8 +++----- example/min_max_paths.cpp | 2 +- example/minimum_degree_ordering.cpp | 5 ++--- example/modify_graph.cpp | 2 +- example/neighbor_bfs.cpp | 2 +- example/ospf-example.cpp | 9 ++++----- example/parallel-compile-time.cpp | 12 ++++-------- example/prim-telephone.cpp | 3 +-- example/print-adjacent-vertices.cpp | 6 ++---- example/print-edges.cpp | 6 ++---- example/print-in-edges.cpp | 6 ++---- example/print-out-edges.cpp | 3 +-- example/property-map-traits-eg.cpp | 2 +- example/quick_tour.cpp | 8 +++----- example/r_c_shortest_paths_example.cpp | 2 +- example/reachable-loop-head.cpp | 5 ++--- example/read_write_dimacs-eg.cpp | 2 +- example/remove_edge_if_bidir.cpp | 3 +-- example/remove_edge_if_undir.cpp | 3 +-- example/roget_components.cpp | 11 +++++------ example/sloan_ordering.cpp | 4 ++-- example/stoer_wagner.cpp | 2 +- example/strong-components.cpp | 2 +- example/strong_components.cpp | 2 +- example/subgraph.cpp | 4 ++-- example/subgraph_properties.cpp | 4 ++-- example/topo-sort-with-sgb.cpp | 2 +- example/undirected_adjacency_list.cpp | 3 +-- example/vertex_basics.cpp | 9 +++------ 48 files changed, 92 insertions(+), 132 deletions(-) diff --git a/example/adj_list_ra_edgelist.cpp b/example/adj_list_ra_edgelist.cpp index a75a1ebd..2a1becce 100644 --- a/example/adj_list_ra_edgelist.cpp +++ b/example/adj_list_ra_edgelist.cpp @@ -25,7 +25,7 @@ main() Graph g(edge_array, edge_array + m, n); for (std::size_t i = 0; i < m; ++i) { - const graph_traits::edge_iterator e = edges(g).first + i; + const auto e = edges(g).first + i; std::cout << *e << " "; } std::cout << std::endl; diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 03f23186..8fa7e726 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -299,7 +299,7 @@ int main (int argc, char const *argv[]) { } random_generator.seed(std::time(0)); - maze m = random_maze(x, y); + auto m = random_maze(x, y); if (m.solve()) std::cout << "Solved the maze." << std::endl; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index 27697a72..626979c5 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -122,7 +122,7 @@ main() u = pos->second; ++i; - std::string hyperlink_name = *i++; + auto hyperlink_name = *i++; std::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { @@ -152,7 +152,7 @@ main() size_type i; for (i = 0; i < num_vertices(g); ++i) { calc_distance_visitor vis(&d_matrix[i][0]); - Traits::vertex_descriptor src = vertices(g).first[i]; + auto src = vertices(g).first[i]; breadth_first_search(g, src, boost::visitor(vis)); } @@ -180,7 +180,7 @@ main() // Do a BFS starting at the home page, recording the parent of each // vertex (where parent is with respect to the search tree). - Traits::vertex_descriptor src = vertices(g).first[0]; + auto src = vertices(g).first[0]; breadth_first_search (g, src, boost::visitor(make_bfs_visitor(record_predecessors(&parent[0], diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 54fc8848..ad1166c0 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -45,7 +45,6 @@ void gen_rand_graph(TG &g, size_t nV, size_t nE) int main(int argc, char* argv[]) { const double epsilon = 0.0000001; - double min_cr, max_cr; ///Minimum and maximum cycle ratio using ccReal_t = std::vector::edge_descriptor>; ccReal_t cc; ///critical cycle @@ -61,9 +60,9 @@ int main(int argc, char* argv[]) for(const auto& vertex : make_range_pair(vertices(tgr))) { vim[vertex] = i++; ///Initialize vertex index property } - max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); + auto max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); std::cout << "Maximum cycle ratio is " << max_cr << std::endl; - min_cr = minimum_cycle_ratio(tgr, vim, ew1, ew2, &cc); + auto min_cr = minimum_cycle_ratio(tgr, vim, ew1, ew2, &cc); std::cout << "Minimum cycle ratio is " << min_cr << std::endl; std::pair cr(.0,.0); std::cout << "Critical cycle:\n"; diff --git a/example/edge-function.cpp b/example/edge-function.cpp index 8675b5df..a8713c4d 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -98,11 +98,9 @@ main() } // Obtain internal property map from the graph - property_map::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); - graph_traits::vertex_descriptor yow, zag, bar; // Get vertex name property map from the graph auto name = get(vertex_name, g); // Get iterators for the vertex set @@ -110,13 +108,13 @@ main() // Find yow.h using name_map_t = property_map::type; name_equals_t predicate1("yow.h", name); - yow = *std::find_if(i, end, predicate1); + auto yow = *std::find_if(i, end, predicate1); // Find zag.o name_equals_t predicate2("zag.o", name); - zag = *std::find_if(i, end, predicate2); + auto zag = *std::find_if(i, end, predicate2); // Find bar.o name_equals_t predicate3("bar.o", name); - bar = *std::find_if(i, end, predicate3); + auto bar = *std::find_if(i, end, predicate3); // Get the edge connecting yow.h to zag.o diff --git a/example/edge_coloring.cpp b/example/edge_coloring.cpp index b0385519..9f8ec4c2 100644 --- a/example/edge_coloring.cpp +++ b/example/edge_coloring.cpp @@ -58,7 +58,7 @@ int main(int, char *[]) for (size_t i = 0; i < sizeof(edges)/sizeof(edges[0]); i++) add_edge(edges[i].first, edges[i].second, G); - size_t colors = edge_coloring(G, get(edge_bundle, G)); + auto colors = edge_coloring(G, get(edge_bundle, G)); std::cout << "Colored using " << colors << " colors" << std::endl; for (size_t i = 0; i < sizeof(edges)/sizeof(edges[0]); i++) { diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 01321f14..1626c16d 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -130,8 +130,7 @@ int main(int , char* []) print_network(G); - property_map::type - flow = get(edge_myflow, G); + auto flow = get(edge_myflow, G); int f = 0; for (const auto& vertex : make_range_pair(vertices(G))) diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index 3a4c5aeb..48db4812 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -99,7 +99,7 @@ int main(int , char* []) { boost::add_edge(6, 8, 9, G); using EdgeIndexMap = boost::property_map::type; - EdgeIndexMap edge_id = boost::get(boost::edge_index, G); + auto edge_id = boost::get(boost::edge_index, G); using IterMap = boost::iterator_property_map; diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index d03c68ed..cbb7af4d 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -50,7 +50,7 @@ using NameToVertex = std::map; Vertex get_vertex(const std::string& name, Graph& g, NameToVertex& names) { - NameToVertex::iterator i = names.find(name); + auto i = names.find(name); if (i == names.end()) i = names.insert(std::make_pair(name, add_vertex(name, g))).first; return i->second; diff --git a/example/girth.cpp b/example/girth.cpp index 24e7f20d..9bcf63c8 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -119,8 +119,7 @@ main() if (q == 0) break; - Graph* g; - g = raman(p, q, 0L, 0L); + auto g = raman(p, q, 0L, 0L); if (g == 0) { std::cerr << " Sorry, I couldn't make that graph (error code " << panic_code << ")" << std::endl; diff --git a/example/graph-assoc-types.cpp b/example/graph-assoc-types.cpp index abd7ffda..8ddd3081 100644 --- a/example/graph-assoc-types.cpp +++ b/example/graph-assoc-types.cpp @@ -28,7 +28,7 @@ template void generic_bar(Graph & g) { // Declare some vertex and edge descriptor variables - typename graph_traits::vertex_descriptor u = vertex(0,g), v = vertex(1,g); + auto u = vertex(0,g), v = vertex(1,g); typename graph_traits::edge_descriptor e1, e2; // Set u and e1 to valid descriptors... v = u; // Make v a handle to the same vertex as u. @@ -65,10 +65,8 @@ foo(Digraph & digraph, typename graph_traits::vertex_descriptor u, typename graph_traits::vertex_descriptor v) { - using edge_t = typename graph_traits::edge_descriptor; - std::pair e1, e2; - e1 = edge(u, v, digraph); - e2 = edge(v, u, digraph); + auto e1 = edge(u, v, digraph); + auto e2 = edge(v, u, digraph); assert(e1.first != e2.first); } template void @@ -76,10 +74,8 @@ bar(Undigraph & undigraph, typename graph_traits::vertex_descriptor u, typename graph_traits::vertex_descriptor v) { - using edge_t = typename graph_traits::edge_descriptor; - std::pair e1, e2; - e1 = edge(u, v, undigraph); - e2 = edge(v, u, undigraph); + auto e1 = edge(u, v, undigraph); + auto e2 = edge(v, u, undigraph); assert(e1.first == e2.first); } diff --git a/example/grid_graph_example.cpp b/example/grid_graph_example.cpp index 796575ec..f5f0f27a 100644 --- a/example/grid_graph_example.cpp +++ b/example/grid_graph_example.cpp @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) { (graph.wrapped(2) ? "W" : "U") << std::endl; // prints "W, U, W" // Start with the first vertex in the graph - Traits::vertex_descriptor first_vertex = vertex(0, graph); + auto first_vertex = vertex(0, graph); print_vertex(first_vertex); // prints "(0, 0, 0)" // Print the next vertex in dimension 0 diff --git a/example/helper.hpp b/example/helper.hpp index 3bacfc6b..9cd81349 100644 --- a/example/helper.hpp +++ b/example/helper.hpp @@ -44,12 +44,12 @@ read_graph(Graph& g, NameMap nm, InputStream& is) std::map verts; for(std::string line; std::getline(is, line); ) { if(line.empty()) continue; - std::size_t index = line.find_first_of(','); + auto index = line.find_first_of(','); std::string first(line, 0, index); std::string second(line, index + 1); - Vertex u = add_named_vertex(g, nm, first, verts); - Vertex v = add_named_vertex(g, nm, second, verts); + auto u = add_named_vertex(g, nm, first, verts); + auto v = add_named_vertex(g, nm, second, verts); add_edge(u, v, g); } return verts; @@ -69,12 +69,11 @@ inline std::map::vertex_descrip read_weighted_graph(Graph& g, NameMap nm, WeightMap wm, InputStream& is) { using Vertex = typename boost::graph_traits::vertex_descriptor; - using Edge = typename boost::graph_traits::edge_descriptor; std::map verts; for(std::string line; std::getline(is, line); ) { if(line.empty()) continue; - std::size_t i = line.find_first_of(','); - std::size_t j = line.find_first_of(',', i + 1); + auto i = line.find_first_of(','); + auto j = line.find_first_of(',', i + 1); std::string first(line, 0, i); std::string second(line, i + 1, j - i - 1); std::string prob(line, j + 1); @@ -85,11 +84,11 @@ read_weighted_graph(Graph& g, NameMap nm, WeightMap wm, InputStream& is) ss >> p; // add the vertices to the graph - Vertex u = add_named_vertex(g, nm, first, verts); - Vertex v = add_named_vertex(g, nm, second, verts); + auto u = add_named_vertex(g, nm, first, verts); + auto v = add_named_vertex(g, nm, second, verts); // add the edge and set the weight - Edge e = add_edge(u, v, g).first; + auto e = add_edge(u, v, g).first; put(wm, e, p); } return verts; diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 4ea35cf6..6600346e 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -89,8 +89,7 @@ main() for (int i=0; i<11; ++i) add_edge(edge_array[i].first, edge_array[i].second, G); - property_map::type name - = get(vertex_first_name, G); + auto name = get(vertex_first_name, G); boost::put(name, 0, "Jeremy"); boost::put(name, 1, "Rich"); diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index 6da7a754..9e5ae844 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -30,8 +30,7 @@ main() std::vector::vertex_descriptor> v1(n), v2(n); - property_map::type - v1_index_map = get(vertex_index, g1), + auto v1_index_map = get(vertex_index, g1), v2_index_map = get(vertex_index, g2); int id = 0; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index b2551234..e1385b04 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -69,8 +69,8 @@ main() for (std::string line; std::getline(datafile, line);) { char_delimiters_separator sep(false, "", ";"); tokenizer <> line_toks(line, sep); - tokenizer <>::iterator i = line_toks.begin(); - std::string actors_name = *i++; + auto i = line_toks.begin(); + auto actors_name = *i++; Vertex u, v; auto [pos, inserted] = actors.insert(std::make_pair(actors_name, Vertex())); if (inserted) { @@ -80,7 +80,7 @@ main() } else u = pos->second; - std::string movie_name = *i++; + auto movie_name = *i++; std::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex())); if (inserted) { diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 17028e6c..21d8a000 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -87,7 +87,7 @@ int main(int , char* []) << std::endl; } { - Vertex s = vertex(0, G); + auto s = vertex(0, G); //king_ordering king_ordering(G, s, inv_perm.rbegin(), get(vertex_color, G), get(vertex_degree, G), get(vertex_index, G)); diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index f2e052df..cbe09801 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -22,12 +22,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, { using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits::vertex_descriptor u; typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph - u = add_vertex(g); + auto u = add_vertex(g); name_in >> name; put(name_map, u, name); // ** Attach name property to vertex u ** } diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 87dceefb..9a96c7f8 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -74,9 +74,8 @@ compute_loop_extent(typename graph_traits < using Vertex = typename graph_traits::vertex_descriptor; using Color = color_traits; - Vertex loop_head, loop_tail; - loop_tail = source(back_edge, g); - loop_head = target(back_edge, g); + auto loop_tail = source(back_edge, g); + auto loop_head = target(back_edge, g); std::vector reachable_from_head(num_vertices(g), Color::white()); diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 9bac63a2..003f9ca7 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -67,14 +67,12 @@ main() Traits::vertex_descriptor s, t; read_dimacs_max_flow(g, capacity, rev, s, t); - long flow; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // Use non-named parameter version - property_map::type - indexmap = get(vertex_index, g); - flow = push_relabel_max_flow(g, s, t, capacity, residual_capacity, rev, indexmap); + auto indexmap = get(vertex_index, g); + auto flow = push_relabel_max_flow(g, s, t, capacity, residual_capacity, rev, indexmap); #else - flow = push_relabel_max_flow(g, s, t); + auto flow = push_relabel_max_flow(g, s, t); #endif std::cout << "c The total flow:" << std::endl; diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index 3f58565a..e4eecfd1 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -71,7 +71,7 @@ main(int , char* []) std::vector p(num_vertices(G)); std::vector d(num_vertices(G)); - Vertex s = *(vertices(G).first); + auto s = *(vertices(G).first); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 dijkstra_shortest_paths diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index 448e705c..c0639fef 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -37,8 +37,7 @@ struct harwell_boeing { harwell_boeing(char* filename) { int Nrhs; - char* Type; - Type = new char[4]; + auto Type = new char[4]; isComplex = false; readHB_info(filename, &M, &N, &nonzeros, &Type, &Nrhs); colptr = (int *)malloc((N+1)*sizeof(int)); @@ -103,7 +102,7 @@ int main(int argc, char* argv[]) //must be BGL directed graph now using Graph = adjacency_list ; - int n = hbs.nrows(); + auto n = hbs.nrows(); std::cout << "n is " << n << std::endl; diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 522bbb7b..788a8edb 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -67,7 +67,7 @@ void modify_demo(MutableGraph& g) u = add_vertex(g); v = add_vertex(g); - std::pair p = add_edge(u, v, g); + auto p = add_edge(u, v, g); assert(num_edges(g) == m + 1); assert(p.second == true); // edge should have been added diff --git a/example/neighbor_bfs.cpp b/example/neighbor_bfs.cpp index e4b4ea21..2963a4ef 100644 --- a/example/neighbor_bfs.cpp +++ b/example/neighbor_bfs.cpp @@ -118,7 +118,7 @@ int main(int , char* []) std::fill_n(d, 5, 0); // The source vertex - Vertex s = *(vertices(G).first); + auto s = *(vertices(G).first); p[s] = s; distance_and_pred_visitor vis(d, &p[0], get(vertex_color, G)); diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 1aa4fb86..da9a5fc8 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -73,10 +73,9 @@ main() dijkstra_shortest_paths(g, router_six, predecessor_map(&parent[0])); #endif - graph_traits::edge_descriptor e; for (size_type i = 0; i < num_vertices(g); ++i) if (parent[i] != i) { - e = edge(parent[i], i, g_dot).first; + auto e = edge(parent[i], i, g_dot).first; put(edge_color, g_dot, e, "black"); } @@ -91,10 +90,10 @@ main() for (const auto& vertex : make_range_pair(vertices(g_dot))) if (parent[vertex] != vertex) { rtable << get(vertex_name, g_dot, vertex) << " "; - vertex_descriptor v = vertex, child; + auto v = vertex; + vertex_descriptor child; int path_cost = 0; - property_map::type - weight_map = get(edge_weight, g); + auto weight_map = get(edge_weight, g); do { path_cost += get(weight_map, edge(parent[v], v, g).first); child = v; diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 9ddb0353..2711429d 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -137,17 +137,13 @@ main() file_dep_graph2 g(input_begin, input_end, n_vertices); #endif - name_map_t - name_map = + auto name_map = get(vertex_name, g); - compile_cost_map_t - compile_cost_map = + auto compile_cost_map = get(vertex_compile_cost, g); - distance_map_t - distance_map = + auto distance_map = get(vertex_distance, g); - color_map_t - color_map = + auto color_map = get(vertex_color, g); { diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 12f4294f..34282bd0 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -53,8 +53,7 @@ main() if (parent[u] != u) edge_attr_map[edge(parent[u], u, g_dot).first]["color"] = "black"; std::ofstream out("figs/telephone-mst-prim.dot"); - graph_property::type & - graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); + auto& graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); graph_edge_attr_map["color"] = "gray"; write_graphviz(out, g_dot); diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 715dcf5f..9e3dcc0c 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -20,12 +20,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, { using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits::vertex_descriptor u; typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph - u = add_vertex(g); + auto u = add_vertex(g); name_in >> name; put(name_map, u, name); // ** Attach name property to vertex u ** } @@ -96,8 +95,7 @@ main() return -1; } // Obtain internal property map from the graph - property_map::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); auto [i, end] = vertices(g); diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 13d0d7e0..6642e057 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -20,12 +20,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, { using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits::vertex_descriptor u; typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph - u = add_vertex(g); + auto u = add_vertex(g); name_in >> name; put(name_map, u, name); // ** Attach name property to vertex u ** } @@ -72,8 +71,7 @@ main() } // Obtain internal property map from the graph - property_map::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); print_dependencies(std::cout, g, get(vertex_name, g)); diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index 2cd1c7d4..e74594c6 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -20,12 +20,11 @@ read_graph_file(std::istream & graph_in, std::istream & name_in, { using size_type = typename graph_traits::vertices_size_type; size_type n_vertices; - typename graph_traits::vertex_descriptor u; typename property_traits::value_type name; graph_in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) { // Add n vertices to the graph - u = add_vertex(g); + auto u = add_vertex(g); name_in >> name; put(name_map, u, name); // ** Attach name property to vertex u ** } @@ -96,8 +95,7 @@ main() } // Obtain internal property map from the graph - property_map::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); auto [i, end] = vertices(g); diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index e1f06ad8..2cd2ebea 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -95,8 +95,7 @@ main() return -1; } // Obtain internal property map from the graph - property_map::type name_map = - get(vertex_name, g); + auto name_map = get(vertex_name, g); read_graph_file(file_in, name_in, g, name_map); auto [i, end] = vertices(g); diff --git a/example/property-map-traits-eg.cpp b/example/property-map-traits-eg.cpp index 71bd708f..cde11b7e 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -16,7 +16,7 @@ main() using graph_t = adjacency_list>; graph_t g; - graph_traits::vertex_descriptor u = add_vertex(g); + auto u = add_vertex(g); auto name_map = get(vertex_name, g); name_map[u] = "Joe"; std::cout << name_map[u] << std::endl; diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index a4005449..4836b427 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -41,7 +41,7 @@ template struct exercise_vertex { std::cout << "\tin-edges: "; for (const auto& e : make_range_pair(in_edges(v, g))) { - Vertex src = source(e, g), targ = target(e, g); + auto src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << "," << name[get(vertex_id, targ)] << ") "; } @@ -93,10 +93,8 @@ int main(int,char*[]) transmission_delay, num_vertices); #endif - boost::property_map::type - vertex_id = get(vertex_index, g); - boost::property_map::type - trans_delay = get(edge_weight, g); + auto vertex_id = get(vertex_index, g); + auto trans_delay = get(edge_weight, g); std::cout << "vertices(g) = "; for (const auto& vertex : make_range_pair(vertices(g))) diff --git a/example/r_c_shortest_paths_example.cpp b/example/r_c_shortest_paths_example.cpp index c20590ce..2fa4d5f5 100644 --- a/example/r_c_shortest_paths_example.cpp +++ b/example/r_c_shortest_paths_example.cpp @@ -163,7 +163,7 @@ class ref_spptw const SPPRC_Example_Graph_Vert_Prop& vert_prop = get( vertex_bundle, g )[target( ed, g )]; new_cont.cost = old_cont.cost + arc_prop.cost; - int& i_time = new_cont.time; + auto& i_time = new_cont.time; i_time = old_cont.time + arc_prop.time; i_time < vert_prop.eat ? i_time = vert_prop.eat : 0; return i_time <= vert_prop.lat ? true : false; diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 0f503a63..d26c2f0c 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -60,11 +60,10 @@ main(int argc, char *argv[]) } loops_out<< "]"; } - property_map::type - eattr_map = get(edge_attribute, g); + auto eattr_map = get(edge_attribute, g); for (const auto& edge : make_range_pair(edges(g))) { loops_out << source(edge, g) << " -> " << target(edge, g) << "["; - std::map& attr_map = eattr_map[edge]; + auto& attr_map = eattr_map[edge]; for (auto eai = attr_map.begin(); eai != attr_map.end(); ++eai) { loops_out << eai->first << "=" << eai->second; diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 8994a401..32c5263b 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -96,7 +96,7 @@ int main() capacity[to_sink] -= to_augment; augmented_flow += to_augment; }else{ - tCapMapValue to_augment = get(capacity, to_sink); + auto to_augment = get(capacity, to_sink); capacity[to_sink] = 0; capacity[from_source] -= to_augment; augmented_flow += to_augment; diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index d75b4622..6dec6620 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -75,8 +75,7 @@ main() #else Graph g(edge_array, edge_array + 6, 4); #endif - property_map::type - weight = get(edge_weight, g); + auto weight = get(edge_weight, g); int w = 0; for (const auto& edge : make_range_pair(edges(g))) diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 1c613f16..004b9794 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -74,8 +74,7 @@ main() #else Graph g(edge_array, edge_array + 5, 4); #endif - property_map::type - weight = get(edge_weight, g); + auto weight = get(edge_weight, g); int w = 0; for (const auto& edge : make_range_pair(edges(g))) diff --git a/example/roget_components.cpp b/example/roget_components.cpp index a1fa5c20..a1c97ea6 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -19,7 +19,6 @@ int main(int argc, char* argv[]) { using namespace boost; - Graph* g; using vertex_t = graph_traits::vertex_descriptor; unsigned long n = 0; unsigned long d = 0; @@ -41,7 +40,7 @@ int main(int argc, char* argv[]) } } - g = (filename ? restore_graph(filename) : roget(n, d, p, s)); + auto g = (filename ? restore_graph(filename) : roget(n, d, p, s)); if (g == NULL) { fprintf(stderr, "Sorry, can't create the graph! (error code %ld)\n", panic_code); @@ -61,7 +60,7 @@ int main(int argc, char* argv[]) auto root = get(v_property(), g); - int num_comp = strong_components + auto num_comp = strong_components (g, make_iterator_property_map(comp.begin(), index_map), root_map(root). discover_time_map(get(z_property(), g)). @@ -84,7 +83,7 @@ int main(int argc, char* argv[]) // from outside the algorithm. for (c = 0; c < num_comp; ++c) { - vertex_t v = strong_comp[c].front(); + auto v = strong_comp[c].front(); std::cout << "Strong component `" << specs(v) << "'"; if (strong_comp[c].size() > 1) { std::cout << " also includes:\n"; @@ -111,9 +110,9 @@ int main(int argc, char* argv[]) // We go in reverse order just to mimic the output ordering in // Knuth's version. for (c = num_comp - 1; c >= 0; --c) { - vertex_t u = strong_comp[c][0]; + auto u = strong_comp[c][0]; for (i = 0; i < strong_comp[c].size(); ++i) { - vertex_t v = strong_comp[c][i]; + auto v = strong_comp[c][i]; for (const auto& edge : make_range_pair(out_edges(v, g))) { auto x = target(edge, g); auto comp_x = comp[index_map[x]]; diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index 8c1bd610..b5d16c0e 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -132,11 +132,11 @@ int main(int , char* []) { //Setting the start node - Vertex s = vertex(0, G); + auto s = vertex(0, G); int ecc; //defining a variable for the pseudoperipheral radius //Calculating the pseudoeperipheral node and radius - Vertex e = pseudo_peripheral_pair(G, s, ecc, get(vertex_color, G), get(vertex_degree, G) ); + auto e = pseudo_peripheral_pair(G, s, ecc, get(vertex_color, G), get(vertex_degree, G) ); std::cout << std::endl; std::cout << "Starting vertex: " << s << std::endl; diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index f0850ebe..eb28edd8 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -45,7 +45,7 @@ int main() BOOST_AUTO(parities, boost::make_one_bit_color_map(num_vertices(g), get(boost::vertex_index, g))); // run the Stoer-Wagner algorithm to obtain the min-cut weight. `parities` is also filled in. - int w = boost::stoer_wagner_min_cut(g, get(boost::edge_weight, g), boost::parity_map(parities)); + auto w = boost::stoer_wagner_min_cut(g, get(boost::edge_weight, g), boost::parity_map(parities)); std::cout << "The min-cut weight of G is " << w << ".\n" << std::endl; assert(w == 7); diff --git a/example/strong-components.cpp b/example/strong-components.cpp index ad813db7..b2525280 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -28,7 +28,7 @@ main() add_edge(5, 2, G); std::vector c(N); - int num = strong_components + auto num = strong_components (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); std::cout << "Total number of components: " << num << std::endl; diff --git a/example/strong_components.cpp b/example/strong_components.cpp index c0f623d7..011f0b91 100644 --- a/example/strong_components.cpp +++ b/example/strong_components.cpp @@ -59,7 +59,7 @@ int main(int, char*[]) std::vector component(num_vertices(G)), discover_time(num_vertices(G)); std::vector color(num_vertices(G)); std::vector root(num_vertices(G)); - int num = strong_components(G, make_iterator_property_map(component.begin(), get(vertex_index, G)), + auto num = strong_components(G, make_iterator_property_map(component.begin(), get(vertex_index, G)), root_map(make_iterator_property_map(root.begin(), get(vertex_index, G))). color_map(make_iterator_property_map(color.begin(), get(vertex_index, G))). discover_time_map(make_iterator_property_map(discover_time.begin(), get(vertex_index, G)))); diff --git a/example/subgraph.cpp b/example/subgraph.cpp index d2e486f7..a4f66775 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -49,8 +49,8 @@ int main(int,char*[]) Graph G0(N); enum { A, B, C, D, E, F}; // for conveniently refering to vertices in G0 - Graph& G1 = G0.create_subgraph(); - Graph& G2 = G0.create_subgraph(); + auto& G1 = G0.create_subgraph(); + auto& G2 = G0.create_subgraph(); enum { A1, B1, C1 }; // for conveniently refering to vertices in G1 enum { A2, B2 }; // for conveniently refering to vertices in G2 diff --git a/example/subgraph_properties.cpp b/example/subgraph_properties.cpp index 0e178203..bf5e74f7 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -57,7 +57,7 @@ int main(int,char*[]) name[E] = "E"; name[F] = "F"; - Graph& G1 = G0.create_subgraph(); + auto& G1 = G0.create_subgraph(); enum { A1, B1, C1 }; // for conveniently refering to vertices in G1 add_vertex(C, G1); // global vertex C becomes local A1 for G1 @@ -84,7 +84,7 @@ int main(int,char*[]) std::cout << " G0[F]= " << boost::get(vertex_name, G0, vertex(F, G0)) << std::endl;// prints: "G0[F]= F" std::cout << " G1[C1]= " << boost::get(vertex_name, G1, vertex(C1, G1)) << std::endl;// prints: "G1[C1]= C1" - Graph& G2 = G0.create_subgraph(); + auto& G2 = G0.create_subgraph(); enum { A2, B2 }; // for conveniently refering to vertices in G2 add_vertex(A, G2); // global vertex A becomes local A2 for G2 diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index 9781b985..311a32f7 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -16,7 +16,7 @@ main() { using namespace boost; const int n_vertices = 7; - Graph *sgb_g = gb_new_graph(n_vertices); + auto sgb_g = gb_new_graph(n_vertices); const char *tasks[] = { "pick up kids from school", diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 3cfa9beb..8328eccc 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -66,8 +66,7 @@ undirected_graph_demo2() const int V = 2; UndirectedGraph undigraph(V); using Weight = typename UndirectedGraph::edge_property_type; - typename property_map::type - weight = get(edge_weight, undigraph); + auto weight = get(edge_weight, undigraph); auto u = vertex(0, undigraph); auto v = vertex(1, undigraph); diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index c5671210..68e632bc 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -81,8 +81,7 @@ struct print_index { using Vertex = typename boost::graph_traits::vertex_descriptor; void operator()(Vertex c) const { - typename boost::property_map::type - id = get(vertex_index, G); + auto id = get(vertex_index, G); std::cout << id[c] << " "; } @@ -98,8 +97,7 @@ struct exercise_vertex { void operator()(Vertex v) const { - typename boost::property_map::type - id = get(vertex_index, g); + auto id = get(vertex_index, g); std::cout << "vertex id: " << id[v] << std::endl; @@ -140,8 +138,7 @@ main() for (int i=0; i<11; ++i) add_edge(edge_array[i].first, edge_array[i].second, g); - boost::property_map::type - id = get(vertex_index, g); + auto id = get(vertex_index, g); std::cout << "vertices(g) = "; for (const auto& vertex : make_range_pair(vertices(g))) From 2945694652bcd394f4d8cba00c0da14ac6a7ecc2 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 10 May 2017 23:09:22 +0200 Subject: [PATCH 20/28] examples: Remove some unused variables. --- example/iteration_macros.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/example/iteration_macros.cpp b/example/iteration_macros.cpp index 773bda2a..563327e8 100644 --- a/example/iteration_macros.cpp +++ b/example/iteration_macros.cpp @@ -29,8 +29,6 @@ int main() add_edge(Rick, Margaret, g); add_edge(John, Benjamin, g); - graph_traits>::vertex_iterator i, end; - graph_traits>::adjacency_iterator ai, a_end; auto index_map = get(vertex_index, g); BGL_FORALL_VERTICES(i, g, adjacency_list<>) { From bb37c8ffa9d958a4fbf3986d8cf28f8913bccaf2 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 11 May 2017 10:42:50 +0200 Subject: [PATCH 21/28] astar_search: Remove unused variable. To avoid a compiler warning. --- include/boost/graph/astar_search.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/graph/astar_search.hpp b/include/boost/graph/astar_search.hpp index 435ccf03..1e4fa34d 100644 --- a/include/boost/graph/astar_search.hpp +++ b/include/boost/graph/astar_search.hpp @@ -325,7 +325,7 @@ namespace boost { bool decreased = relax(e, g, weight, predecessor, distance, combine, compare); - Distance w_d = combine(get(distance, v), e_weight); + combine(get(distance, v), e_weight); if (decreased) { vis.edge_relaxed(e, g); Distance w_rank = combine(get(distance, w), h(w)); From dba5732ee8b102ea27bdda4f32aea801e9c17cef Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 11 May 2017 10:50:10 +0200 Subject: [PATCH 22/28] examples: Comment-out unused types and variables. These are meant as documentation, not code, so just leave them commented out. This lets the build succeed with -Werror. --- example/graph-assoc-types.cpp | 10 ++++++---- example/two_graphs_common_spanning_trees.cpp | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/example/graph-assoc-types.cpp b/example/graph-assoc-types.cpp index 8ddd3081..0019f3d0 100644 --- a/example/graph-assoc-types.cpp +++ b/example/graph-assoc-types.cpp @@ -14,11 +14,13 @@ template void generic_foo(Graph & g) { // Access descriptor types - using Vertex = typename graph_traits::vertex_descriptor; - using Edge = typename graph_traits::edge_descriptor; + // using Vertex = typename graph_traits::vertex_descriptor; + // using Edge = typename graph_traits::edge_descriptor; + // Access category types - using Dir = typename graph_traits::directed_category; - using Par = typename graph_traits::edge_parallel_category; + // using Dir = typename graph_traits::directed_category; + // using Par = typename graph_traits::edge_parallel_category; + // Access iterator types... // Access size types... // Now do something useful... diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index 6846349b..1671a5c1 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -75,9 +75,11 @@ int main(int argc, char **argv) inL ); + // Here you can play with the trees that the algorithm has found. + /* for(const auto& vec : coll) { - // Here you can play with the trees that the algorithm has found. } + */ return 0; } From 496edd1396d6ec733b15aea0937b7527f913e12f Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 11 May 2017 11:23:32 +0200 Subject: [PATCH 23/28] examples: C++11: Use std::sto*() instead of boost::lexical_cast<>(). --- example/actor_clustering.cpp | 5 ++--- example/astar_maze.cpp | 5 ++--- example/fr_layout.cpp | 7 +++---- example/hawick_circuits.cpp | 3 +-- example/implicit_graph.cpp | 3 +-- example/kruskal-telephone.cpp | 3 +-- example/loops_dfs.cpp | 1 - example/mcgregor_subgraphs_example.cpp | 1 - example/ospf-example.cpp | 1 - example/prim-telephone.cpp | 3 +-- 10 files changed, 11 insertions(+), 21 deletions(-) diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 54a7f424..cd22fc8c 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "range_pair.hpp" @@ -52,7 +51,7 @@ void load_actor_graph(std::istream& in, ActorGraph& g) using Tok = tokenizer>; Tok tok(line, char_separator(" ")); for (const auto& id : tok) { - auto actor_id = lexical_cast(id); + auto actor_id = std::stoi(id); auto v = actors.find(actor_id); if (v == actors.end()) { auto new_vertex = add_vertex(Actor(actor_id), g); @@ -132,7 +131,7 @@ int main(int argc, char* argv[]) out_file = argv[on_arg]; } else if (arg == "-threshold") { ++on_arg; assert(on_arg < argc); - threshold = lexical_cast(argv[on_arg]); + threshold = std::stod(argv[on_arg]); } else if (arg == "-normalize") { normalize = true; } else { diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 8fa7e726..181aa04f 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -294,8 +293,8 @@ int main (int argc, char const *argv[]) { std::size_t y = 10; if (argc == 3) { - x = boost::lexical_cast(argv[1]); - y = boost::lexical_cast(argv[2]); + x = std::stoul(argv[1]); + y = std::stoul(argv[2]); } random_generator.seed(std::time(0)); diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index cbb7af4d..6efea4fa 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -90,10 +89,10 @@ int main(int argc, char* argv[]) if (arg == "--iterations") { ++arg_idx; if (arg_idx >= argc) { usage(); return -1; } - iterations = lexical_cast(argv[arg_idx]); + iterations = std::stoi(argv[arg_idx]); } else { - if (width == 0.0) width = lexical_cast(arg); - else if (height == 0.0) height = lexical_cast(arg); + if (width == 0.0) width = std::stod(arg); + else if (height == 0.0) height = std::stod(arg); else { usage(); return -1; diff --git a/example/hawick_circuits.cpp b/example/hawick_circuits.cpp index bc838f76..cbbcdfc8 100644 --- a/example/hawick_circuits.cpp +++ b/example/hawick_circuits.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +79,7 @@ int main(int argc, char const* argv[]) { return EXIT_FAILURE; } - unsigned int num_vertices = boost::lexical_cast(argv[1]); + unsigned int num_vertices = std::stoul(argv[1]); std::istream_iterator first_vertex(std::cin), last_vertex; boost::directed_graph<> graph; build_graph(graph, num_vertices, first_vertex, last_vertex); diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index a29cfcc9..ee7adf63 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include "range_pair.hpp" @@ -460,7 +459,7 @@ int main (int argc, char const *argv[]) { // Specify the size of the graph on the command line, or use a default size // of 5. - std::size_t n = argc == 2 ? boost::lexical_cast(argv[1]) : 5; + std::size_t n = argc == 2 ? std::stoul(argv[1]) : 5; // Create a small ring graph. ring_graph g(n); diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 480f5108..dde44fa6 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include "range_pair.hpp" @@ -25,7 +24,7 @@ main() Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); for (const auto& edge : make_range_pair(edges(g_dot))) { - int weight = lexical_cast(edge_attr_map[edge]["label"]); + int weight = std::stoi(edge_attr_map[edge]["label"]); property edge_property(weight); add_edge(source(edge, g_dot), target(edge, g_dot), edge_property, g); } diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 9a96c7f8..c97be174 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/example/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index 0b18365b..4af47e28 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index da9a5fc8..2fdbbc9a 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -8,7 +8,6 @@ #include // for file I/O #include // for read/write_graphviz() #include -#include #include "range_pair.hpp" namespace boost { diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 34282bd0..1e72f567 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include "range_pair.hpp" @@ -26,7 +25,7 @@ main() Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); for (const auto& edge : make_range_pair(edges(g_dot))) { - auto weight = lexical_cast(edge_attr_map[edge]["label"]); + auto weight = std::stoi(edge_attr_map[edge]["label"]); property edge_property(weight); add_edge(source(edge, g_dot), target(edge, g_dot), edge_property, g); } From e4fde2b39578d8cd036cffa7361a8596b90fbf5b Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 12 May 2017 11:02:48 +0200 Subject: [PATCH 24/28] examples: C++11: Use std::shared_ptr instead of boost::shared_ptr. --- example/fr_layout.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 6efea4fa..45189390 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include "range_pair.hpp" using namespace boost; @@ -72,7 +71,7 @@ class progress_cooling : public linear_cooling } private: - shared_ptr display; + std::shared_ptr display; }; int main(int argc, char* argv[]) From 8ab7fc051f54fb88f4ab850669df23f49f9f3a93 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 12 May 2017 22:05:04 +0200 Subject: [PATCH 25/28] examples: C++11: Use the new includes. --- example/astar-cities.cpp | 2 +- example/dfs.cpp | 2 +- example/dfs_parenthesis.cpp | 2 +- example/file_dependencies.cpp | 2 +- example/knights_tour.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index ff4be6f3..b9bcc658 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -21,7 +21,7 @@ #include #include #include -#include // for sqrt +#include // for sqrt using namespace boost; diff --git a/example/dfs.cpp b/example/dfs.cpp index a77b42ed..021a5b8b 100644 --- a/example/dfs.cpp +++ b/example/dfs.cpp @@ -7,7 +7,7 @@ // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include -#include +#include #include #include diff --git a/example/dfs_parenthesis.cpp b/example/dfs_parenthesis.cpp index 3e8a650b..d3ec2eb4 100644 --- a/example/dfs_parenthesis.cpp +++ b/example/dfs_parenthesis.cpp @@ -12,7 +12,7 @@ // (0(2(3(4(11)4)3)2)0) #include -#include +#include #include #include diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index 0d09f522..9d0ebb0a 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 3f5d21b9..d86df0d9 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -6,7 +6,7 @@ // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include -#include +#include #include #include #include From e15388e7d6b221b7f8ac75f9dcdfddd519abfd01 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 12 May 2017 22:07:14 +0200 Subject: [PATCH 26/28] examples: C++11: Use nullptr. --- example/astar-cities.cpp | 2 +- example/astar_maze.cpp | 2 +- example/cycle_ratio_example.cpp | 2 +- example/minimum_degree_ordering.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index b9bcc658..3bee02ba 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -167,7 +167,7 @@ int main(int argc, char **argv) // pick random start/goal - boost::mt19937 gen(time(0)); + boost::mt19937 gen(time(nullptr)); auto start = random_vertex(g, gen); auto goal = random_vertex(g, gen); diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 181aa04f..c0a7475f 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -297,7 +297,7 @@ int main (int argc, char const *argv[]) { y = std::stoul(argv[2]); } - random_generator.seed(std::time(0)); + random_generator.seed(std::time(nullptr)); auto m = random_maze(x, y); if (m.solve()) diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index ad1166c0..65c1a26c 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -32,7 +32,7 @@ void gen_rand_graph(TG &g, size_t nV, size_t nE) { g.clear(); mt19937 rng; - rng.seed(uint32_t(time(0))); + rng.seed(uint32_t(time(nullptr))); boost::generate_random_graph(g, nV, nE, rng, true, true); boost::uniform_real<> ur(-1,10); boost::variate_generator> ew1rg(rng, ur); diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index c0639fef..c972f7e5 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -41,19 +41,19 @@ struct harwell_boeing isComplex = false; readHB_info(filename, &M, &N, &nonzeros, &Type, &Nrhs); colptr = (int *)malloc((N+1)*sizeof(int)); - if ( colptr == NULL ) IOHBTerminate("Insufficient memory for colptr.\n"); + if ( colptr == nullptr ) IOHBTerminate("Insufficient memory for colptr.\n"); rowind = (int *)malloc(nonzeros*sizeof(int)); - if ( rowind == NULL ) IOHBTerminate("Insufficient memory for rowind.\n"); + if ( rowind == nullptr ) IOHBTerminate("Insufficient memory for rowind.\n"); if ( Type[0] == 'C' ) { isComplex = true; val = (double *)malloc(nonzeros*sizeof(double)*2); - if ( val == NULL ) IOHBTerminate("Insufficient memory for val.\n"); + if ( val == nullptr ) IOHBTerminate("Insufficient memory for val.\n"); } else { if ( Type[0] != 'P' ) { val = (double *)malloc(nonzeros*sizeof(double)); - if ( val == NULL ) IOHBTerminate("Insufficient memory for val.\n"); + if ( val == nullptr ) IOHBTerminate("Insufficient memory for val.\n"); } } From 5b82ca37173d5b2637d183e1170782d04228faf0 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 12 May 2017 22:18:49 +0200 Subject: [PATCH 27/28] examples: C++11: More use of range-based for loops. --- example/copy-example.cpp | 4 ++-- example/cuthill_mckee_ordering.cpp | 2 +- example/edge_basics.cpp | 6 +++--- example/edge_coloring.cpp | 10 +++++----- example/exterior_property_map.cpp | 6 +++--- example/filtered-copy-example.cpp | 4 ++-- example/interior_pmap_bundled.cpp | 6 +++--- example/interior_property_map.cpp | 6 +++--- example/king_ordering.cpp | 6 +++--- example/knights_tour.cpp | 2 +- example/modify_graph.cpp | 2 +- example/remove_edge_if_bidir.cpp | 6 +++--- example/remove_edge_if_undir.cpp | 6 +++--- example/sloan_ordering.cpp | 6 +++--- example/transpose-example.cpp | 4 ++-- example/vertex_basics.cpp | 6 +++--- 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 882031da..25322104 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -33,8 +33,8 @@ main() E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; - for (int i = 0; i < 12; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); print_graph(G, name_map); std::cout << std::endl; diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 1cd65d48..42e6c94a 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -40,7 +40,7 @@ int main(int , char* []) using size_type = graph_traits::vertices_size_type; using Pair = std::pair; - Pair edges[14] = { Pair(0,3), //a-d + Pair edges[] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c Pair(1,4), //b-e diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index 8825bd12..06c4ff2b 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -69,15 +69,15 @@ main() using MyGraph = adjacency_list<>; using Pair = std::pair; - Pair edge_array[8] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), + Pair edge_array[] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1) }; // Construct a graph using the edge_array (passing in pointers // (iterators) to the beginning and end of the array), and // specifying the number of vertices as 5 MyGraph G(5); - for (int i=0; i<8; ++i) - add_edge(edge_array[i].first, edge_array[i].second, G); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, G); // Use the STL for_each algorithm to "exercise" all of the edges in // the graph diff --git a/example/edge_coloring.cpp b/example/edge_coloring.cpp index 9f8ec4c2..685bf05f 100644 --- a/example/edge_coloring.cpp +++ b/example/edge_coloring.cpp @@ -38,7 +38,7 @@ int main(int, char *[]) using Graph = adjacency_list; using Pair = std::pair; - Pair edges[14] = { Pair(0,3), //a-d + Pair edges[] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c Pair(1,4), //b-e @@ -55,14 +55,14 @@ int main(int, char *[]) Graph G(10); - for (size_t i = 0; i < sizeof(edges)/sizeof(edges[0]); i++) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); auto colors = edge_coloring(G, get(edge_bundle, G)); std::cout << "Colored using " << colors << " colors" << std::endl; - for (size_t i = 0; i < sizeof(edges)/sizeof(edges[0]); i++) { - std::cout << " " << (char)('a' + edges[i].first) << "-" << (char)('a' + edges[i].second) << ": " << G[edge(edges[i].first, edges[i].second, G).first] << std::endl; + for (const auto& edge : edges) { + std::cout << " " << (char)('a' + edge.first) << "-" << (char)('a' + edge.second) << ": " << G[edge(edge.first, edge.second, G).first] << std::endl; } return 0; diff --git a/example/exterior_property_map.cpp b/example/exterior_property_map.cpp index b96389b8..f86da59d 100644 --- a/example/exterior_property_map.cpp +++ b/example/exterior_property_map.cpp @@ -79,13 +79,13 @@ main(int, char*[]) using MyGraphType = adjacency_list<>; using Pair = std::pair; - Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), + Pair edge_array[] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; MyGraphType G(5); - for (int i=0; i<11; ++i) - add_edge(edge_array[i].first, edge_array[i].second, G); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, G); who_owes_who(edges(G).first, edges(G).second, G, names); diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 2a7324fd..9ab3b746 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -46,8 +46,8 @@ main() E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; - for (int i = 0; i < 12; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); print_graph(G, name_map); std::cout << std::endl; diff --git a/example/interior_pmap_bundled.cpp b/example/interior_pmap_bundled.cpp index 08f3dff3..3d5d8086 100644 --- a/example/interior_pmap_bundled.cpp +++ b/example/interior_pmap_bundled.cpp @@ -68,13 +68,13 @@ main() using MyGraphType = adjacency_list; using Pair = std::pair; - Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), + Pair edge_array[] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; MyGraphType G(5); - for (int i=0; i<11; ++i) - add_edge(edge_array[i].first, edge_array[i].second, G); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, G); G[0].first_name = "Jeremy"; G[1].first_name = "Rich"; diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 6600346e..fdfca046 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -81,13 +81,13 @@ main() property>; using Pair = std::pair; - Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), + Pair edge_array[] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; MyGraphType G(5); - for (int i=0; i<11; ++i) - add_edge(edge_array[i].first, edge_array[i].second, G); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, G); auto name = get(vertex_first_name, G); diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 21d8a000..28ce5841 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -40,7 +40,7 @@ int main(int , char* []) using size_type = graph_traits::vertices_size_type; using Pair = std::pair; - Pair edges[14] = { Pair(0,3), //a-d + Pair edges[] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c Pair(1,4), //b-e @@ -56,8 +56,8 @@ int main(int , char* []) Pair(6,7) }; //g-h Graph G(10); - for (int i = 0; i < 14; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); auto deg = get(vertex_degree, G); for (const auto& vertex : make_range_pair(vertices(G))) diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index d86df0d9..efbc35f4 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -20,7 +20,7 @@ using namespace boost; using Position = std::pair; Position - knight_jumps[8] = { + knight_jumps[] = { Position(2, -1), Position(1, -2), Position(-1, -2), diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 788a8edb..07ccd9f4 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -178,7 +178,7 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); - for (const auto & vertex : make_range_pair(vertices(g))) { + for (const auto& vertex : make_range_pair(vertices(g))) { for (const auto& adjacent_vertex : make_range_pair(adjacent_vertices(vertex, g))) assert(adjacent_vertex != vertex); } diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 6dec6620..d32dd112 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -63,15 +63,15 @@ int main() { using Edge = std::pair; - Edge edge_array[6] = { Edge(0,3), Edge(0,2), Edge(0, 3), + Edge edge_array[] = { Edge(0,3), Edge(0,2), Edge(0, 3), Edge(1,3), Edge(2, 0), Edge(3, 2) }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(4); - for (std::size_t j = 0; j < 6; ++j) - add_edge(edge_array[j].first, edge_array[j].second, g); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, g); #else Graph g(edge_array, edge_array + 6, 4); #endif diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 004b9794..868cd5d7 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -62,15 +62,15 @@ int main() { using Edge = std::pair; - Edge edge_array[5] = { Edge(0, 3), Edge(0, 3), + Edge edge_array[] = { Edge(0, 3), Edge(0, 3), Edge(1, 3), Edge(2, 0), Edge(3, 2) }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(4); - for (std::size_t j = 0; j < 5; ++j) - add_edge(edge_array[j].first, edge_array[j].second, g); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, g); #else Graph g(edge_array, edge_array + 5, 4); #endif diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index b5d16c0e..d6270ff4 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -88,7 +88,7 @@ int main(int , char* []) using Pair = std::pair; - Pair edges[14] = { Pair(0,3), //a-d + Pair edges[] = { Pair(0,3), //a-d Pair(0,5), //a-f Pair(1,2), //b-c Pair(1,4), //b-e @@ -106,8 +106,8 @@ int main(int , char* []) //Creating a graph and adding the edges from above into it Graph G(10); - for (int i = 0; i < 14; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (const auto& edge : edges) + add_edge(edge.first, edge.second, G); //Creating a property_map with the degrees of the degrees of each vertex auto deg = get(vertex_degree, G); diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index a0ecacca..5003abd8 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -30,8 +30,8 @@ main() E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; - for (int i = 0; i < 12; ++i) - add_edge(edge_array[i].first, edge_array[i].second, G); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, G); print_graph(G, name_map); std::cout << std::endl; diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index 68e632bc..d77ca407 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -129,14 +129,14 @@ main() using MyGraphType = adjacency_list; using Pair = std::pair; - Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), + Pair edge_array[] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4), Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1), Pair(3,4), Pair(4,0), Pair(4,1) }; /* Construct a graph using the edge_array*/ MyGraphType g(5); - for (int i=0; i<11; ++i) - add_edge(edge_array[i].first, edge_array[i].second, g); + for (const auto& edge : edge_array) + add_edge(edge.first, edge.second, g); auto id = get(vertex_index, g); From 6bd1dda9b08bb9c9f61b3c407a0fafce63dad443 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 15 May 2017 11:29:21 +0200 Subject: [PATCH 28/28] examples: C++11: Replace BOOST_FOREACH() with range-based for. --- example/graph-thingie.cpp | 4 ++-- example/incremental-components-eg.cpp | 9 ++++----- example/incremental_components.cpp | 9 ++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index f6a69fcf..ebd17240 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include "range_pair.hpp" #include #include #include @@ -93,7 +93,7 @@ const char* dot = std::cout << "graph " << get("name",dp,&graph) << " (" << get("identifier",dp,&graph) << ")\n\n"; - BOOST_FOREACH( graph_t::vertex_descriptor v, vertices(graph) ) { + for (auto v : make_range_pair(vertices(graph))) { std::cout << "vertex " << get("node_id",dp,v) << " (" << get("label",dp,v) << ")\n"; } diff --git a/example/incremental-components-eg.cpp b/example/incremental-components-eg.cpp index c2eeba5a..19192f35 100644 --- a/example/incremental-components-eg.cpp +++ b/example/incremental-components-eg.cpp @@ -11,10 +11,10 @@ #include #include -#include #include #include #include +#include "range_pair.hpp" using namespace boost; @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) ds.union_set(4, 0); ds.union_set(2, 5); - BOOST_FOREACH(Vertex current_vertex, vertices(graph)) { + for (auto current_vertex : make_range_pair(vertices(graph))) { std::cout << "representative[" << current_vertex << "] = " << ds.find_set(current_vertex) << std::endl; } @@ -68,12 +68,11 @@ int main(int argc, char* argv[]) Components components(parent.begin(), parent.end()); // Iterate through the component indices - BOOST_FOREACH(VertexIndex component_index, components) { + for (auto component_index : components) { std::cout << "component " << component_index << " contains: "; // Iterate through the child vertex indices for [component_index] - BOOST_FOREACH(VertexIndex child_index, - components[component_index]) { + for (auto child_index : make_range_pair(components[component_index])) { std::cout << child_index << " "; } diff --git a/example/incremental_components.cpp b/example/incremental_components.cpp index fa04242c..89e145ef 100644 --- a/example/incremental_components.cpp +++ b/example/incremental_components.cpp @@ -10,11 +10,11 @@ #include #include -#include #include #include #include #include +#include "range_pair.hpp" /* @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) print_graph(graph, get(boost::vertex_index, graph)); std::cout << std::endl; - BOOST_FOREACH(Vertex current_vertex, vertices(graph)) { + for ( auto current_vertex : make_range_pair(vertices(graph)) ) { std::cout << "representative[" << current_vertex << "] = " << ds.find_set(current_vertex) << std::endl; } @@ -99,12 +99,11 @@ int main(int argc, char* argv[]) Components components(parent.begin(), parent.end()); // Iterate through the component indices - BOOST_FOREACH(VertexIndex current_index, components) { + for (auto current_index : components) { std::cout << "component " << current_index << " contains: "; // Iterate through the child vertex indices for [current_index] - BOOST_FOREACH(VertexIndex child_index, - components[current_index]) { + for (auto child_index : make_range_pair(components[current_index])) { std::cout << child_index << " "; }