diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index cc0d48fd8..e220129e9 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -72,12 +72,8 @@ int main(int argc, const char** argv) 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); std::ifstream name_in(argc >= 3 ? argv[2] : "makefile-target-names.dat"); std::ifstream compile_cost_in( diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index 5564a9e9c..87527e7c6 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -52,13 +52,13 @@ void load_actor_graph(std::istream& in, ActorGraph& g) // Map from the actor numbers on this line to the actor vertices typedef tokenizer< char_separator< char > > Tok; Tok tok(line, char_separator< char >(" ")); - for (Tok::iterator id = tok.begin(); id != tok.end(); ++id) + for (const auto& id : tok) { - int actor_id = lexical_cast< int >(*id); - std::map< int, Vertex >::iterator v = actors.find(actor_id); + auto actor_id = lexical_cast< int >(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); } @@ -68,11 +68,9 @@ void load_actor_graph(std::istream& in, ActorGraph& g) } } - for (std::vector< Vertex >::iterator i = actors_in_movie.begin(); - i != actors_in_movie.end(); ++i) + for (auto i = actors_in_movie.begin(); i != actors_in_movie.end(); ++i) { - for (std::vector< Vertex >::iterator j = i + 1; - j != actors_in_movie.end(); ++j) + for (auto j = i + 1; j != actors_in_movie.end(); ++j) { if (!edge(*i, *j, g).second) add_edge(*i, *j, g); @@ -86,16 +84,14 @@ std::ostream& 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< Graph >::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< Graph >::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 916a98c02..b8a984d66 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -61,10 +61,8 @@ int main(int, char*[]) const int V = 5; Graph g(V); - property_map< Graph, std::size_t VertexProperties::* >::type id - = get(&VertexProperties::index, g); - property_map< Graph, std::string EdgeProperties::* >::type name - = get(&EdgeProperties::name, g); + auto id = get(&VertexProperties::index, g); + auto name = get(&EdgeProperties::name, g); boost::graph_traits< Graph >::vertex_iterator vi, viend; int vnum = 0; diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 3437e6abd..7c615ac9d 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -86,8 +86,8 @@ class distance_heuristic : public astar_heuristic< Graph, CostType > distance_heuristic(LocMap l, Vertex goal) : 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); } @@ -174,7 +174,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; @@ -185,9 +185,9 @@ int main(int argc, char** argv) } // pick random start/goal - boost::mt19937 gen(std::time(0)); - vertex start = random_vertex(g, gen); - vertex goal = random_vertex(g, gen); + boost::mt19937 gen(time(0)); + auto start = random_vertex(g, gen); + auto goal = random_vertex(g, gen); cout << "Start vertex: " << name[start] << endl; cout << "Goal vertex: " << name[goal] << endl; @@ -215,7 +215,7 @@ int main(int argc, char** argv) catch (found_goal fg) { // found a path to the goal list< vertex > 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) @@ -223,7 +223,7 @@ int main(int argc, char** argv) } cout << "Shortest path from " << name[start] << " to " << name[goal] << ": "; - list< vertex >::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 4c437ee87..089b569f7 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -201,8 +201,8 @@ bool maze::solve() dist_map distance; boost::associative_property_map< dist_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); @@ -218,7 +218,7 @@ bool maze::solve() { // 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]; @@ -285,9 +285,9 @@ std::size_t random_int(std::size_t a, std::size_t b) // Generate a maze with a random assignment of barriers. void random_maze(maze& m) { - 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) @@ -297,7 +297,7 @@ void random_maze(maze& m) // 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. @@ -310,7 +310,7 @@ void random_maze(maze& m) 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 69bce6397..2de9c3529 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -23,8 +23,7 @@ template < typename Graph, typename ParentMap > 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 @@ -74,8 +73,7 @@ int main() Graph g(edge_array, edge_array + n_edges, N); #endif graph_traits< Graph >::edge_iterator ei, ei_end; - property_map< Graph, int EdgeProperties::* >::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]; @@ -115,9 +113,8 @@ int 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] << "[label=\"" diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index 564c70313..5bd66e39a 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -81,7 +81,7 @@ int main() Size time = 0; typedef property_map< graph_t, std::size_t VertexProps::* >::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 bc0da3bc3..5b19e9c01 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -16,16 +16,15 @@ template < typename Graph, typename VertexNameMap, typename TransDelayMap > 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< Graph >::edge_descriptor ed; @@ -78,13 +77,13 @@ int main() typedef adjacency_list< listS, vecS, directedS, VP, EP > graph_t; graph_t g; - property_map< graph_t, char VP::* >::type name_map = get(&VP::name, g); - property_map< graph_t, double EP::* >::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< graph_t, char VP::* >::type VertexNameMap; - graph_traits< graph_t >::vertex_descriptor a = *vertices(g).first; + auto a = *vertices(g).first; bfs_name_printer< VertexNameMap > 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 1c9ddc5d7..09d7b0947 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, boost::visitor(boost::make_bfs_visitor( diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index 7beb9fa5d..5408246df 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, boost::visitor(boost::make_neighbor_bfs_visitor( diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 8c1b58946..17380fd5d 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -45,10 +45,9 @@ int 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< vertex_t > art_points; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index 3d640c8df..cae0cfaba 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -29,9 +29,8 @@ class calc_distance_visitor : public boost::bfs_visitor<> void tree_edge( typename boost::graph_traits< Graph >::edge_descriptor e, Graph& g) { - typename boost::graph_traits< Graph >::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; } @@ -95,9 +94,8 @@ int main(int argc, const char** argv) NameVertexMap name2vertex; Graph g; - typedef property_map< Graph, vertex_name_t >::type NameMap; - NameMap node_name = get(vertex_name, g); - property_map< Graph, edge_name_t >::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. @@ -113,7 +111,7 @@ int main(int argc, const char** argv) bool inserted; Vertex u, v; - std::list< std::string >::iterator i = line_toks.begin(); + auto i = line_toks.begin(); boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); @@ -210,6 +208,8 @@ int main(int argc, const char** argv) // the tree nodes in the order that we want to print out: // a directory-structure like format. std::vector< size_type > dfs_distances(num_vertices(g), 0); + + using NameMap = property_map< Graph, vertex_name_t >::type; print_tree_visitor< NameMap, size_type* > 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 5dd8d03e4..67b1bfcde 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -85,17 +85,15 @@ int main() 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< default_color_type > color(num_vertices(g)); std::vector< long > 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 bf551867f..f8251df43 100644 --- a/example/bron_kerbosch_clique_number.cpp +++ b/example/bron_kerbosch_clique_number.cpp @@ -29,7 +29,7 @@ int 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 4f176a428..fdc91f88e 100644 --- a/example/bucket_sorter.cpp +++ b/example/bucket_sorter.cpp @@ -47,7 +47,7 @@ int main() 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()); @@ -75,7 +75,7 @@ int main() 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()); @@ -93,7 +93,7 @@ int main() std::size_t current = rand() % N; if (!my_bucket_sorter[current].empty()) { - int v = my_bucket_sorter[current].top(); + auto v = my_bucket_sorter[current].top(); my_bucket_sorter[current].pop(); bucket[v] = rand() % N; my_bucket_sorter.push(v); @@ -105,7 +105,7 @@ int main() std::size_t current = rand() % N; if (!my_bucket_sorter[current].empty()) { - int v = my_bucket_sorter[current].top(); + auto v = my_bucket_sorter[current].top(); bucket[v] = rand() % N; my_bucket_sorter.update(v); } diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index 7695f8d24..ffcb96314 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) add_edge(1, 5, g); // Initialize the interior edge index - property_map< graph, edge_index_t >::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits< graph >::edges_size_type edge_count = 0; graph_traits< graph >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) @@ -69,10 +69,9 @@ int main(int argc, char** argv) make_iterator_property_map(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 929d5e236..df05f2e13 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -32,8 +32,7 @@ int main() 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; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) diff --git a/example/city_visitor.cpp b/example/city_visitor.cpp index ba98c25e8..4b72bf330 100644 --- a/example/city_visitor.cpp +++ b/example/city_visitor.cpp @@ -137,7 +137,7 @@ int main(int, char*[]) cout << endl; /* Get the source vertex */ - boost::graph_traits< Graph >::vertex_descriptor s = vertex(SanJose, G); + auto s = vertex(SanJose, G); cout << "*** Breadth First ***" << endl; breadth_first_search(G, s, diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index cb2ef39bf..4c05c2a23 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -52,7 +52,7 @@ int 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< Graph >::vertex_iterator i, end; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 034a78807..396abb3f7 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -24,7 +24,7 @@ int main() add_edge(2, 5, G); std::vector< int > 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 4af273d23..8fd6efc4c 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< int > component(num_vertices(G)); - int num = connected_components(G, &component[0]); + auto num = connected_components(G, &component[0]); std::vector< int >::size_type i; cout << "Total number of components: " << num << endl; diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 7b629d479..9a0b345d4 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -30,7 +30,7 @@ int main() 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 13a329f2c..6406e9337 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -62,26 +62,24 @@ int main(int, char*[]) graph_traits< Graph >::vertex_iterator ui, ui_end; - property_map< Graph, vertex_degree_t >::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< Graph, vertex_index_t >::type index_map - = get(vertex_index, G); + auto index_map = get(vertex_index, G); std::cout << "original bandwidth: " << bandwidth(G) << std::endl; std::vector< Vertex > inv_perm(num_vertices(G)); std::vector< size_type > 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< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -94,14 +92,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< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -121,8 +118,7 @@ int main(int, char*[]) cout << "Reverse Cuthill-McKee ordering:" << endl; cout << " "; - for (std::vector< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + 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 63033848c..6176366eb 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 121bebe66..adca0cb8f 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -50,12 +50,9 @@ int main(int argc, char* argv[]) ccReal_t cc; /// critical cycle grap_real_t tgr; - property_map< grap_real_t, vertex_index_t >::type vim - = get(vertex_index, tgr); - property_map< grap_real_t, edge_weight_t >::type ew1 - = get(edge_weight, tgr); - property_map< grap_real_t, edge_weight2_t >::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; @@ -72,12 +69,12 @@ int main(int argc, char* argv[]) cout << "Minimum cycle ratio is " << min_cr << endl; std::pair< double, double > 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 * 2); diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 4e22457dd..016c4ac62 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -50,8 +50,7 @@ int main() add_edge(u, x, 1, g); add_edge(v, x, -2, g); - property_map< graph_t, vertex_distance_t >::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 @@ -61,7 +60,7 @@ int main() default_dijkstra_visitor vis; std::less< int > compare; closed_plus< int > combine; - property_map< graph_t, edge_weight_t >::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< int >::max)(), 0); #else diff --git a/example/dave.cpp b/example/dave.cpp index 0cf807fb8..74e9322cd 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -169,8 +169,7 @@ int main(int, char*[]) }; Graph G(N); - boost::property_map< Graph, vertex_index_t >::type vertex_id - = get(vertex_index, G); + auto vertex_id = get(vertex_index, G); std::vector< weight_t > distance(N, (numeric_limits< weight_t >::max)()); typedef boost::graph_traits< Graph >::vertex_descriptor Vertex; diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 89bca7b00..4e9757095 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -44,13 +44,11 @@ int main(int, char*[]) graph_traits< graph_t >::vertex_iterator i, iend; graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes); - property_map< graph_t, edge_weight_t >::type weightmap - = get(edge_weight, g); + auto weightmap = get(edge_weight, g); // Manually intialize the vertex index and name maps - property_map< graph_t, vertex_index_t >::type indexmap - = get(vertex_index, g); - property_map< graph_t, vertex_name_t >::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) { @@ -58,12 +56,10 @@ int main(int, char*[]) name[*i] = 'A' + c; } - vertex_descriptor s = vertex(A, g); + auto s = vertex(A, g); - property_map< graph_t, vertex_distance_t >::type d - = get(vertex_distance, g); - property_map< graph_t, vertex_predecessor_t >::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; @@ -87,9 +83,8 @@ int 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 62b55120a..1092ece84 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -39,11 +39,10 @@ int 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< graph_t, edge_weight_t >::type weightmap - = get(edge_weight, g); + auto weightmap = get(edge_weight, g); std::vector< vertex_descriptor > p(num_vertices(g)); std::vector< int > 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( @@ -73,9 +72,8 @@ int 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 b0f072d77..3d737b1a3 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -43,11 +43,10 @@ int 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< graph_t, edge_weight_t >::type weightmap - = get(edge_weight, g); + auto weightmap = get(edge_weight, g); std::vector< vertex_descriptor > p(num_vertices(g)); std::vector< int > 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( @@ -78,8 +77,7 @@ int main(int, char*[]) 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 4eb55ff3f..41fe874ec 100644 --- a/example/directed_graph.cpp +++ b/example/directed_graph.cpp @@ -18,8 +18,8 @@ int main(int, char*[]) typedef boost::directed_graph<> Graph; Graph g; - boost::graph_traits< Graph >::vertex_descriptor v0 = g.add_vertex(); - boost::graph_traits< Graph >::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 54345ae0a..5f93d54ea 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -30,7 +30,7 @@ min_degree_vertex(Graph& g) { 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) @@ -86,12 +86,9 @@ typename graph_traits< VertexListGraph >::degree_size_type edge_connectivity( 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) @@ -139,11 +136,10 @@ typename graph_traits< VertexListGraph >::degree_size_type edge_connectivity( } 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) @@ -166,19 +162,15 @@ int 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 = disconnecting_set.begin(); - i != disconnecting_set.end(); ++i) + for (auto i = disconnecting_set.begin(); i != disconnecting_set.end(); ++i) std::cout << "(" << attr_map[source(*i, g)]["label"] << "," << attr_map[target(*i, g)]["label"] << ") "; std::cout << "}." << std::endl; diff --git a/example/edge-function.cpp b/example/edge-function.cpp index e3898afcf..98810e876 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -111,12 +111,12 @@ int main(int argc, const char** argv) 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 + typedef property_map< graph_type, vertex_name_t >::type name_map_t; name_equals_t< name_map_t > predicate1("yow.h", name); yow = *std::find_if(i, end, predicate1); // Find zag.o diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index 038ed691b..fac231971 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -45,12 +45,12 @@ template < class Graph > struct exercise_edge void operator()(Edge e) const { // begin - // Get the associated vertex type out of the edge using the - // 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); + // Get the associated vertex type out of the edge using the + // edge_traits class + // Use the source() and target() functions to access the vertices + // that belong to Edge e + 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 2e05a8b4c..e273a3d3f 100644 --- a/example/edge_connectivity.cpp +++ b/example/edge_connectivity.cpp @@ -49,8 +49,7 @@ int main() typedef graph_traits< UndirectedGraph >::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; std::cout << "The disconnecting set is {"; diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index 837a2c810..6c2c6f724 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -60,7 +60,7 @@ class edge_stream_iterator } 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 7da442fd8..9fe2272d2 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -80,10 +80,8 @@ template < class Graph > void print_network(const Graph& G) typename boost::graph_traits< Graph >::out_edge_iterator OutEdgeIter; typedef typename boost::graph_traits< Graph >::in_edge_iterator InEdgeIter; - typename property_map< Graph, edge_mycapacity_t >::const_type capacity - = get(edge_mycapacity, G); - typename property_map< Graph, edge_myflow_t >::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 a27718b72..a07bde38b 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -61,11 +61,9 @@ int 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 a3db9da9a..a61aa4bbd 100644 --- a/example/family_tree.cpp +++ b/example/family_tree.cpp @@ -38,8 +38,7 @@ int main() 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); + auto index_map = get(vertex_index, g); for (boost::tie(i, end) = vertices(g); i != end; ++i) { diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 7cd7002c9..19490c55e 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -45,7 +45,7 @@ int main() 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 ed6b653d7..9f5a191a0 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -41,8 +41,8 @@ int main() using namespace boost; typedef adjacency_list< multisetS, vecS, directedS, no_property, - property< edge_weight_t, int > > - Graph; + property< edge_weight_t, int > > + Graph; typedef property_map< Graph, edge_weight_t >::type EdgeWeightMap; enum @@ -65,7 +65,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< Graph >::out_edge_iterator f, l; diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index 09804f7c5..9058435c3 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -49,14 +49,14 @@ void merge_vertex(typename boost::graph_traits< Graph >::vertex_descriptor u, ++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); @@ -131,8 +131,8 @@ int main() add_edge(3, 4, EdgeProperty('h'), g); add_edge(0, 1, EdgeProperty('c'), g); - property_map< graph_type, vertex_index_t >::type id = get(vertex_index, g); - property_map< graph_type, edge_name_t >::type name = get(edge_name, g); + auto id = get(vertex_index, g); + auto name = get(edge_name, g); graph_traits< graph_type >::vertex_iterator i, end; graph_traits< graph_type >::out_edge_iterator ei, edge_end; diff --git a/example/girth.cpp b/example/girth.cpp index 3df89b01b..a55aae2a0 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -75,7 +75,7 @@ class diameter_and_girth_visitor : public boost::bfs_visitor<> 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]; @@ -83,7 +83,7 @@ class diameter_and_girth_visitor : public boost::bfs_visitor<> } 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 3902a0fe6..eaa5dc825 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -52,18 +52,16 @@ int main() graph_t graph(0); dynamic_properties dp; - property_map< graph_t, vertex_name_t >::type vname - = get(vertex_name, graph); + auto vname = get(vertex_name, graph); dp.property("node_id", vname); - property_map< graph_t, vertex_label_t >::type vlabel - = get(vertex_label_t(), graph); + auto vlabel = get(vertex_label_t(), graph); dp.property("label", vlabel); - property_map< graph_t, vertex_root_t >::type root = get(vertex_root, graph); + auto root = get(vertex_root, graph); dp.property("root", root); - property_map< graph_t, edge_name_t >::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 29058a384..4fa08efff 100644 --- a/example/graph_as_tree.cpp +++ b/example/graph_as_tree.cpp @@ -39,13 +39,12 @@ int main() graph_t g; - vertex_t a = add_vertex(g), b = add_vertex(g), c = 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< graph_t, vertex_name_t >::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 83ca9f2eb..e09afc954 100644 --- a/example/grid_graph_properties.cpp +++ b/example/grid_graph_properties.cpp @@ -35,7 +35,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 c7a3c1c73..54346e5e6 100644 --- a/example/hawick_circuits.cpp +++ b/example/hawick_circuits.cpp @@ -28,10 +28,7 @@ template < typename OutputStream > 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 de462ad69..7793cb55a 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -223,7 +223,7 @@ class ring_incident_edge_iterator 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 65abac3bf..b5cc9e92d 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) graph_traits< Graph >::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" << pm[v] << endl; } diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 9a9b7e2d6..92f3bddf0 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -61,7 +61,7 @@ void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) // Access the propety acessor type for this graph typedef typename property_map< Graph, vertex_first_name_t >::const_type NamePA; - NamePA name = get(vertex_first_name, G); + auto name = get(vertex_first_name, G); typedef typename boost::property_traits< NamePA >::value_type NameType; diff --git a/example/iteration_macros.cpp b/example/iteration_macros.cpp index ef2b08b27..8d722f28e 100644 --- a/example/iteration_macros.cpp +++ b/example/iteration_macros.cpp @@ -45,8 +45,7 @@ int main() 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); + auto index_map = get(vertex_index, g); BGL_FORALL_VERTICES(i, g, adjacency_list<>) { diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 90d22b280..025bdafe8 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -36,7 +36,7 @@ int 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 1ee274db0..97417b038 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -58,10 +58,8 @@ int main(int argc, const char** argv) 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 b52d4462c..abe88a665 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -65,7 +65,7 @@ class bacon_number_recorder : public default_bfs_visitor 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; } diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index 9ef613009..ad3350915 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -62,26 +62,24 @@ int main(int, char*[]) graph_traits< Graph >::vertex_iterator ui, ui_end; - property_map< Graph, vertex_degree_t >::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< Graph, vertex_index_t >::type index_map - = get(vertex_index, G); + auto index_map = get(vertex_index, G); std::cout << "original bandwidth: " << bandwidth(G) << std::endl; std::vector< Vertex > inv_perm(num_vertices(G)); std::vector< size_type > 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< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -100,8 +98,7 @@ int main(int, char*[]) get(vertex_degree, G), get(vertex_index, G)); cout << "King ordering starting at: " << s << endl; cout << " "; - for (std::vector< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -121,8 +118,7 @@ int main(int, char*[]) cout << "King ordering:" << endl; cout << " "; - for (std::vector< Vertex >::const_iterator i = inv_perm.begin(); - i != inv_perm.end(); ++i) + 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 4d8c41b7e..890f03a13 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -26,7 +26,7 @@ int main() std::size_t num_edges = sizeof(edge_array) / sizeof(E); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(num_nodes); - property_map< Graph, edge_weight_t >::type weightmap = get(edge_weight, g); + auto = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { Edge e; @@ -38,14 +38,14 @@ int 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(); - ei != spanning_tree.end(); ++ei) + for (auto ei = spanning_tree.begin(); ei != spanning_tree.end(); ++ei) { std::cout << source(*ei, g) << " <--> " << target(*ei, g) << " with weight of " << weight[*ei] << std::endl; diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index c88337c55..78f628962 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -30,8 +30,7 @@ int main() 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) { @@ -45,7 +44,7 @@ int main() 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]); @@ -54,13 +53,11 @@ int 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 e9779e633..3ce3f2698 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) add_edge(4, 5, g); // Initialize the interior edge index - property_map< graph, edge_index_t >::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits< graph >::edges_size_type edge_count = 0; graph_traits< graph >::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 7d8676ebd..7001fe4e4 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -76,8 +76,7 @@ int main(int argc, const char** argv) 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 @@ -89,7 +88,7 @@ int main(int argc, const char** argv) // 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 507498ecd..008349d9f 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -19,7 +19,7 @@ int 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 b56dd83a3..e080307b3 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -133,20 +133,18 @@ int 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< Graph, vertex_attribute_t >::type vattr_map - = get(vertex_attribute, g); - property_map< Graph, edge_attribute_t >::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; @@ -167,9 +165,7 @@ int main(int argc, char* argv[]) for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; - for (std::map< std::string, std::string >::iterator ai - = vattr_map[*vi].begin(); - ai != vattr_map[*vi].end(); ++ai) + 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()) @@ -181,10 +177,8 @@ int 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< std::string, std::string >& attr_map = eattr_map[*ei]; - for (std::map< std::string, std::string >::iterator eai - = attr_map.begin(); - eai != attr_map.end(); ++eai) + 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 f9c101a7d..bf9a1d186 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -41,7 +41,7 @@ int main(int argc, char** argv) add_edge(0, 10, g); // Initialize the interior edge index - property_map< graph, edge_index_t >::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits< graph >::edges_size_type edge_count = 0; graph_traits< graph >::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 4647f1c09..92b1294d9 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) << 2 * num_vertices(g) - 4 << " faces." << std::endl; // Initialize the interior edge index - property_map< graph, edge_index_t >::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits< graph >::edges_size_type edge_count = 0; graph_traits< graph >::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 3c8a4fbb9..a558820dd 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -75,8 +75,7 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for (std::vector< std::string >::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 @@ -106,8 +105,7 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for (std::vector< std::string >::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 diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 170356888..ca7eed5e3 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -62,11 +62,9 @@ int 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/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index f0b74fc99..287a47a9c 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -81,14 +81,12 @@ int main(int argc, char* argv[]) property< edge_name_t, unsigned int > > Graph; - typedef property_map< Graph, vertex_name_t >::type VertexNameMap; - // Test maximum and unique variants on known graphs Graph graph_simple1, graph_simple2; example_callback< Graph > 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 d0cfee821..7b41bb3d6 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -71,7 +71,7 @@ int 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 d09c7f6f9..66d7cb9a1 100644 --- a/example/miles_span.cpp +++ b/example/miles_span.cpp @@ -102,11 +102,9 @@ int main(int argc, char* argv[]) long sp_length = 0; // Use the "z" utility field for distance. - typedef property_map< Graph*, z_property< long > >::type Distance; - Distance d = get(z_property< long >(), g); + auto d = get(z_property< long >(), g); // Use the "w" property for parent - typedef property_map< Graph*, w_property< Vertex* > >::type Parent; - Parent p = get(w_property< Vertex* >(), g); + auto p = get(w_property< Vertex* >(), g); total_length_visitor< Distance > 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 fabf4c942..740d31124 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -59,7 +59,7 @@ int main(int, char*[]) #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle iterator constructors Graph G(num_nodes); - property_map< Graph, edge_weight_t >::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< Graph >::edge_descriptor e; @@ -69,7 +69,7 @@ int main(int, char*[]) } #else Graph G(edges, edges + n_edges, weights, num_nodes); - property_map< Graph, edge_weight_t >::type weightmap = get(edge_weight, G); + auto weightmap = get(edge_weight, G); #endif std::vector< Vertex > p(num_vertices(G)); diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index c096ccf6d..38044a166 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -146,8 +146,7 @@ int main(int argc, char* argv[]) Vector supernode_sizes(n, 1); // init has to be 1 - boost::property_map< Graph, vertex_index_t >::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 9c8836e07..acad2c47b 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -47,8 +47,7 @@ template < class MutableGraph > 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< MutableGraph, edge_name_t >::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 2beb4b6e9..ca3e2d76a 100644 --- a/example/neighbor_bfs.cpp +++ b/example/neighbor_bfs.cpp @@ -65,16 +65,14 @@ class distance_and_pred_visitor : public neighbor_bfs_visitor<> template < class Edge, class Graph > void tree_out_edge(Edge e, const Graph& g) const { - typename graph_traits< Graph >::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 < class Edge, class Graph > void tree_in_edge(Edge e, const Graph& g) const { - typename graph_traits< Graph >::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 5235eb28c..16003f88f 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -112,8 +112,8 @@ int main() add_edge(3, 4, EdgeProperty("harry"), g); add_edge(0, 1, EdgeProperty("chandler"), g); - property_map< graph_type, vertex_index_t >::type id = get(vertex_index, g); - property_map< graph_type, edge_name_t >::type name = get(edge_name, g); + auto id = get(vertex_index, g); + auto name = get(edge_name, g); graph_traits< graph_type >::vertex_iterator i, end; graph_traits< graph_type >::out_edge_iterator ei, edge_end; diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 54d30a1d5..d0b44df2a 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -49,7 +49,7 @@ int main(int argc, const char** argv) 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); } @@ -71,8 +71,8 @@ int main(int argc, const char** argv) #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 std::vector< int > distance(num_vertices(g)); - property_map< Graph, edge_weight_t >::type weightmap = get(edge_weight, g); - property_map< Graph, vertex_index_t >::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< int >(), closed_plus< int >(), (std::numeric_limits< int >::max)(), 0, default_dijkstra_visitor()); diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index f67e34c0d..e96e9c3bf 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -71,7 +71,7 @@ int main(int argc, char** argv) add_edge(5, 8, g); // Initialize the interior edge index - property_map< graph, edge_index_t >::type e_index = get(edge_index, g); + auto e_index = get(edge_index, g); graph_traits< graph >::edges_size_type edge_count = 0; graph_traits< graph >::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 d9a78758a..ad44df9b4 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -23,7 +23,7 @@ int main() int weights[] = { 1, 1, 2, 7, 3, 1, 1 }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 Graph g(num_nodes); - property_map< Graph, edge_weight_t >::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< Graph >::edge_descriptor e; @@ -37,9 +37,8 @@ int main() std::vector< graph_traits< Graph >::vertex_descriptor > p(num_vertices(g)); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map< Graph, vertex_distance_t >::type distance - = get(vertex_distance, g); - property_map< Graph, vertex_index_t >::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()); #else diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 40b05fc15..e5dd4df9d 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -30,21 +30,20 @@ int main() 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< Graph, vertex_index_t >::type indexmap = get(vertex_index, g); + auto indexmap = get(vertex_index, g); std::vector< std::size_t > 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 3df924324..7c86caac2 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -17,7 +17,7 @@ int main() 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 e95619b33..286b81b11 100644 --- a/example/property_iterator.cpp +++ b/example/property_iterator.cpp @@ -106,14 +106,12 @@ int main(int argc, char* argv[]) std::cout << write(graph); std::cout << "radii:" << std::endl; - graph_property_iter_range< Graph, radius_t >::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< Graph, stiff_t >::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 04a6fa485..cf146de1e 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -56,20 +56,17 @@ int main() 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< Graph, vertex_index_t >::type indexmap = get(vertex_index, g); - long flow = push_relabel_max_flow( + 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; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 8d79b72b7..85f3c5189 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -32,8 +32,7 @@ void 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; - ++p.first) + for (auto p = vertices(g); p.first != p.second; ++p.first) { print_vertex_name(*p.first, name_map); std::cout << ' '; @@ -95,9 +94,8 @@ int main() 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 25d1f5e11..f952c976b 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -24,8 +24,7 @@ template < class Graph > struct exercise_vertex void operator()(const Vertex& v) const { using namespace boost; - typename property_map< Graph, vertex_index_t >::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 @@ -36,7 +35,7 @@ template < class Graph > struct exercise_vertex ++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)] << ") "; } @@ -106,7 +105,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< Graph, edge_weight_t >::type weightmap = get(edge_weight, g); + auto weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { graph_traits< Graph >::edge_descriptor e; diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index fcb90ff1e..aa05ab0a1 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -42,8 +42,7 @@ int main(int argc, char* argv[]) make_iterator_property_map( reachable_from_head.begin(), get(vertex_index, g), c)); - property_map< GraphvizDigraph, vertex_attribute_t >::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) @@ -64,9 +63,7 @@ int main(int argc, char* argv[]) for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; - for (std::map< std::string, std::string >::iterator ai - = vattr_map[*vi].begin(); - ai != vattr_map[*vi].end(); ++ai) + 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()) @@ -81,9 +78,7 @@ int main(int argc, char* argv[]) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; std::map< std::string, std::string >& attr_map = eattr_map[*ei]; - for (std::map< std::string, std::string >::iterator eai - = attr_map.begin(); - eai != attr_map.end(); ++eai) + 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 e3e50b0d9..2d9f3dd3d 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -56,8 +56,7 @@ int main(int argc, char* argv[]) << " node [shape=\"box\"];\n" << " edge [style=\"bold\"];\n"; - property_map< Graph, vertex_attribute_t >::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_in); i != i_end; ++i) { diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index d3b395598..3b6348a43 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -35,15 +35,13 @@ int main() graph_t graph(0); dynamic_properties dp; - property_map< graph_t, vertex_name_t >::type name = get(vertex_name, graph); + auto name = get(vertex_name, graph); dp.property("node_id", name); - property_map< graph_t, vertex_color_t >::type mass - = get(vertex_color, graph); + auto mass = get(vertex_color, graph); dp.property("mass", mass); - property_map< graph_t, edge_weight_t >::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 d6435679f..9d7f670c5 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -78,10 +78,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*/ @@ -95,8 +93,8 @@ int main() 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); @@ -104,7 +102,7 @@ int main() { 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 a58df802d..9be499fdc 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -50,7 +50,7 @@ struct has_weight_greater_than bool operator()(graph_traits< Graph >::edge_descriptor e) { #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map< Graph, edge_weight_t >::type weight = get(edge_weight, g); + auto weight = get(edge_weight, g); return get(weight, e) > w; #else // This version of get() breaks VC++ @@ -81,7 +81,7 @@ int main() for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; - property_map< Graph, vertex_index_t >::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 3f4b62e86..0d5f49b37 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -49,7 +49,7 @@ struct has_weight_greater_than bool operator()(graph_traits< Graph >::edge_descriptor e) { #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - property_map< Graph, edge_weight_t >::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 5347acca6..a90b1a9dd 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -63,11 +63,9 @@ int main(int argc, char* argv[]) // a separate field for marking colors, so we use the w field. std::vector< int > comp(num_vertices(g)); - property_map< Graph*, vertex_index_t >::type index_map - = get(vertex_index, g); + auto index_map = get(vertex_index, g); - property_map< Graph*, v_property< vertex_t > >::type root - = get(v_property< vertex_t >(), g); + auto root = get(v_property< vertex_t >(), g); int num_comp = strong_components(g, make_iterator_property_map(comp.begin(), index_map), @@ -131,8 +129,8 @@ int main(int argc, char* argv[]) graph_traits< Graph* >::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; diff --git a/example/scc.cpp b/example/scc.cpp index 142316db9..94dc7d08a 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -31,8 +31,7 @@ int 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; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index 538e10601..f3b98d1ea 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -106,13 +106,12 @@ int main(int, char*[]) graph_traits< Graph >::vertex_iterator ui, ui_end; // Creating a property_map with the degrees of the degrees of each vertex - property_map< Graph, vertex_degree_t >::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< Graph, vertex_index_t >::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; @@ -147,8 +146,7 @@ int main(int, char*[]) cout << "Sloan ordering starting at: " << s << endl; cout << " "; - for (std::vector< Vertex >::const_iterator i = sloan_order.begin(); - i != sloan_order.end(); ++i) + for (auto i = sloan_order.begin(); i != sloan_order.end(); ++i) cout << index_map[*i] << " "; cout << endl; @@ -192,8 +190,7 @@ int main(int, char*[]) cout << endl << "Sloan ordering without a start-vertex:" << endl; cout << " "; - for (std::vector< Vertex >::const_iterator i = sloan_order.begin(); - i != sloan_order.end(); ++i) + 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 12265daf0..4e5d876ba 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -31,8 +31,7 @@ int 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 ac9316fad..17d217f8b 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -60,7 +60,7 @@ int main(int, char*[]) F }; // for conveniently refering to vertices in G0 - property_map< Graph, vertex_name_t >::type name = get(vertex_name_t(), G0); + auto name = get(vertex_name_t(), G0); name[A] = "A"; name[B] = "B"; name[C] = "C"; @@ -80,7 +80,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< Graph, vertex_name_t >::type name1 = get(vertex_name_t(), G1); + auto name1 = get(vertex_name_t(), G1); name1[A1] = "A1"; std::cout << std::endl @@ -120,7 +120,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< Graph, vertex_name_t >::type name2 = get(vertex_name_t(), G2); + auto name2 = get(vertex_name_t(), G2); name2[A2] = "A2"; std::cout << std::endl diff --git a/example/successive_shortest_path_nonnegative_weights_example.cpp b/example/successive_shortest_path_nonnegative_weights_example.cpp index 017972038..0b0fb7fd4 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 0905973a7..e07c53fa1 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -28,9 +28,7 @@ template < typename OutputStream > struct cycle_printer { // Get the property map containing the vertex indices // so we can print them. - typedef - typename property_map< Graph, vertex_index_t >::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 42c07e2ea..d4120b696 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -45,8 +45,7 @@ int main() std::reverse(topo_order.begin(), topo_order.end()); int n = 1; - for (std::vector< vertex_t >::iterator i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << n << ": " << leda_g[*i] << std::endl; return EXIT_SUCCESS; diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index 7453c3d3b..eb43a89f5 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -36,8 +36,7 @@ int 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(); - i != topo_order.rend(); ++i, ++n) + 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 6579d0e04..52b30ffcd 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -36,8 +36,7 @@ int main() vertex_index_map(identity_property_map())); int n = 1; - for (std::deque< int >::iterator i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << tasks[*i] << std::endl; return EXIT_SUCCESS; diff --git a/example/topo-sort2.cpp b/example/topo-sort2.cpp index 80aa3412b..97c15e0a8 100644 --- a/example/topo-sort2.cpp +++ b/example/topo-sort2.cpp @@ -36,8 +36,7 @@ int main() vertex_index_map(identity_property_map())); int n = 1; - for (std::deque< int >::iterator i = topo_order.begin(); - i != topo_order.end(); ++i, ++n) + for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) std::cout << tasks[*i] << std::endl; return EXIT_SUCCESS; diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index 38dc4667c..b5ee845ba 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -54,15 +54,14 @@ int main(int, char*[]) Graph G(edges, edges + 6, 6); #endif - boost::property_map< Graph, vertex_index_t >::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(); ii != c.rend(); ++ii) + 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 618a288b7..3f7d8fe10 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -30,7 +30,7 @@ int main() 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 824556dbe..ba0d54107 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -62,8 +62,7 @@ int main(int argc, char** argv) boost::two_graphs_common_spanning_trees( iG, iG_o, vG, vG_o, tree_collector, inL); - std::vector< std::vector< bool > >::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 9e3601493..4836d50e1 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -14,13 +14,12 @@ template < typename UndirectedGraph > void 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); @@ -39,15 +38,13 @@ template < typename DirectedGraph > void 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); @@ -68,15 +65,14 @@ template < typename UndirectedGraph > void 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); @@ -92,8 +88,7 @@ template < typename UndirectedGraph > void undirected_graph_demo2() std::cout << "the edges incident to v: "; typename boost::graph_traits< UndirectedGraph >::out_edge_iterator e, e_end; - typename boost::graph_traits< UndirectedGraph >::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 0c0365ceb..3fa2847c1 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< Graph >::vertex_descriptor v0 = g.add_vertex(); - boost::graph_traits< Graph >::vertex_descriptor v1 = g.add_vertex(); - boost::graph_traits< Graph >::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 c1a3b0b70..0971334c0 100644 --- a/example/vertex-name-property.cpp +++ b/example/vertex-name-property.cpp @@ -67,8 +67,7 @@ int main(int argc, const char** argv) } // 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 107fd5ebc..4cbc0bf3e 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -61,11 +61,10 @@ template < class Graph > struct print_edge typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; void operator()(Edge e) const { - typename boost::property_map< Graph, vertex_index_t >::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 330fe28c8..235df83dd 100644 --- a/example/vf2_sub_graph_iso_multi_example.cpp +++ b/example/vf2_sub_graph_iso_multi_example.cpp @@ -69,16 +69,9 @@ int main() add_edge(5, 0, edge_property('s'), graph2); // create predicates - typedef property_map< graph_type, vertex_name_t >::type vertex_name_map_t; - typedef property_map_equivalent< vertex_name_map_t, vertex_name_map_t > - vertex_comp_t; - vertex_comp_t vertex_comp = make_property_map_equivalent( + auto vertex_comp = make_property_map_equivalent( get(vertex_name, graph1), get(vertex_name, graph2)); - - typedef property_map< graph_type, edge_name_t >::type edge_name_map_t; - typedef property_map_equivalent< edge_name_map_t, edge_name_map_t > - edge_comp_t; - edge_comp_t edge_comp = make_property_map_equivalent( + auto edge_comp = make_property_map_equivalent( get(edge_name, graph1), get(edge_name, graph2)); // Create callback