From bb0fc3a38c485e244cefb12c33928879c59d1f82 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Thu, 1 Nov 2001 20:30:32 +0000 Subject: [PATCH] various fixes [SVN r11513] --- example/accum-compile-times.cpp | 78 +++++------------ example/accumulate-eg.cpp | 57 ------------- example/bellman-example.cpp | 9 +- example/bellman_ford.cpp | 98 ---------------------- example/bfs-name-printer.cpp | 2 +- example/bfs_neighbor.cpp | 4 +- example/binary-method-problem.cpp | 89 -------------------- example/copy-example.cpp | 2 +- example/dijkstra-example.cpp | 2 +- example/edge-connectivity.cpp | 2 +- example/edmunds-karp-eg.cpp | 2 +- example/kruskal-example.cpp | 2 +- example/kruskal-telephone.cpp | 2 +- example/lic.cpp | 46 ---------- example/makefile-dependencies.dat | 20 +++++ example/makefile-target-names.dat | 15 ++++ example/parallel-compile-time.cpp | 46 +++------- example/prim-example.cpp | 15 ++-- example/target-compile-costs.dat | 15 ++++ include/boost/graph/dag_shortest_paths.hpp | 10 +-- 20 files changed, 105 insertions(+), 411 deletions(-) delete mode 100644 example/accumulate-eg.cpp delete mode 100644 example/bellman_ford.cpp delete mode 100644 example/binary-method-problem.cpp delete mode 100644 example/lic.cpp create mode 100644 example/makefile-dependencies.dat create mode 100644 example/makefile-target-names.dat create mode 100644 example/target-compile-costs.dat diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 38bfcedb..190b2a25 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -48,82 +48,46 @@ namespace boost using namespace boost; -typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list - listS, // Store vertex set in a std::list - directedS, // The file dependency graph is directed +typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list + listS, // Store vertex set in a std::list + directedS, // The file dependency graph is directed // vertex properties - property < vertex_name_t, - std::string, - property < - vertex_compile_cost_t, float, - property < - vertex_distance_t, float, - property < - vertex_color_t, -default_color_type > >>>, + property < vertex_name_t, std::string, + property < vertex_compile_cost_t, float, + property < vertex_distance_t, float, + property < vertex_color_t, default_color_type > > > >, // an edge property - property < -edge_weight_t, float >> + property < edge_weight_t, float > > file_dep_graph2; -typedef - graph_traits < - file_dep_graph2 >::vertex_descriptor - vertex_t; -typedef - graph_traits < - file_dep_graph2 >::edge_descriptor - edge_t; +typedef graph_traits::vertex_descriptor vertex_t; +typedef graph_traits::edge_descriptor edge_t; int main() { std::ifstream file_in("makefile-dependencies.dat"); - typedef - graph_traits < - file_dep_graph2 >::vertices_size_type - size_type; + typedef graph_traits::vertices_size_type size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices - std::istream_iterator < std::pair < size_type, - size_type > >input_begin(file_in), input_end; + std::istream_iterator > + input_begin(file_in), input_end; file_dep_graph2 g(input_begin, input_end, n_vertices); - typedef - property_map < - file_dep_graph2, - vertex_name_t >::type - name_map_t; - typedef - property_map < - file_dep_graph2, - vertex_compile_cost_t >::type + typedef property_map < file_dep_graph2, vertex_name_t >::type name_map_t; + typedef property_map < file_dep_graph2, vertex_compile_cost_t >::type compile_cost_map_t; - typedef - property_map < - file_dep_graph2, - vertex_distance_t >::type + typedef property_map ::type distance_map_t; - typedef - property_map < - file_dep_graph2, - vertex_color_t >::type + typedef property_map ::type color_map_t; - name_map_t - name_map = - get(vertex_name, g); - compile_cost_map_t - compile_cost_map = - get(vertex_compile_cost, g); - distance_map_t - distance_map = - get(vertex_distance, g); - color_map_t - color_map = - get(vertex_color, g); + name_map_t name_map = get(vertex_name, g); + compile_cost_map_t compile_cost_map = get(vertex_compile_cost, g); + distance_map_t distance_map = get(vertex_distance, g); + color_map_t color_map = get(vertex_color, g); std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); diff --git a/example/accumulate-eg.cpp b/example/accumulate-eg.cpp deleted file mode 100644 index 8d28afdb..00000000 --- a/example/accumulate-eg.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//======================================================================= -// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, -// -// This file is part of the Boost Graph Library -// -// You should have received a copy of the License Agreement for the -// Boost Graph Library along with the software; see the file LICENSE. -// If not, contact Office of Research, Indiana University, -// Bloomington, IN 47405. -// -// Permission to modify the code and to distribute the code is -// granted, provided the text of this NOTICE is retained, a notice if -// the code was modified is included with the above COPYRIGHT NOTICE -// and with the COPYRIGHT NOTICE in the LICENSE file, and that the -// LICENSE file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= -#include -#include -#include -#include -#include - -template < typename InputIterator, typename T, typename BinaryOperator > - T accumulate(InputIterator first, InputIterator last, T init, - BinaryOperator binary_op) -{ - for (; first != last; ++first) - init = binary_op(init, *first); - return init; -} - - -int -main() -{ - // using accumulate with a vector - std::vector < double >x(10, 1.0); - double sum1; - sum1 = std::accumulate(x.begin(), x.end(), 0.0, std::plus < double >()); - - // using accumulate with a linked list - std::list < double >y; - double sum2; - // copy vector's values into the list - std::copy(x.begin(), x.end(), std::back_inserter(y)); - sum2 = std::accumulate(y.begin(), y.end(), 0.0, std::plus < double >()); - assert(sum1 == sum2); // they should be equal - - return 0; -} diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index e03502c8..bf61ad21 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -78,7 +78,7 @@ main() int weight[n_edges] = { -4, 8, 5, -2, 9, -3, 7, 2, 6, 7 }; typedef adjacency_list < vecS, vecS, directedS, - no_property, property < edge_weight_t, int >>Graph; + no_property, property < edge_weight_t, int > > Graph; Graph g(edge_array.begin(), edge_array.end()); graph_traits < Graph >::edge_iterator ei, ei_end; int i = 0; @@ -86,7 +86,7 @@ main() get(edge_weight, g)[*ei] = weight[i]; std::vector < int >distance(N, std::numeric_limits < short >::max()); - std::vector < int >parent(N); + std::vector < std::size_t >parent(N); for (i = 0; i < N; ++i) parent[i] = i; distance[z] = 0; @@ -103,10 +103,6 @@ main() std::cout << "negative cycle" << std::endl; std::ofstream dot_file("figs/bellman-eg.dot"); -#if 0 - write_graphviz(dot_file, g, make_label_writer(name), - make_edge_writer(g, &parent[0])); -#else dot_file << "digraph D {\n" << " rankdir=LR\n" << " size=\"5,3\"\n" @@ -129,6 +125,5 @@ main() } } dot_file << "}"; -#endif return EXIT_SUCCESS; } diff --git a/example/bellman_ford.cpp b/example/bellman_ford.cpp deleted file mode 100644 index 6425b103..00000000 --- a/example/bellman_ford.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//======================================================================= -// Copyright 1997, 1998, 1999, 2000 University of Notre Dame. -// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek -// -// This file is part of the Boost Graph Library -// -// You should have received a copy of the License Agreement for the -// Boost Graph Library along with the software; see the file LICENSE. -// If not, contact Office of Research, University of Notre Dame, Notre -// Dame, IN 46556. -// -// Permission to modify the code and to distribute modified code is -// granted, provided the text of this NOTICE is retained, a notice that -// the code was modified is included with the above COPYRIGHT NOTICE and -// with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE -// file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// Example, page 533 CLR -// -// u*===*v -// *|\ ** -// / | \ / | -// z | x | -// \ | / \ | -// **/ *| -// x----*y -// -// (didn't draw the y->z edge) -// -// Sample Output (distance and parent): -// -// u: 2 v -// v: 4 x -// x: 7 z -// y: -2 u -// z: 0 z -// - -int -main(int,char*) -{ - enum { u, v, x, y, z, N }; - char name[] = "uvxyz"; - - typedef std::pair E; - E edges[] = { E(u,y), E(u,x), E(u,v), - E(v,u), - E(x,y), E(x,v), - E(y,v), E(y,z), - E(z,u), E(z,x) }; - - int weight[] = { -4, 8, 5, - -2, - 9, -3, - 7, 2, - 6, 7 }; - - typedef boost::edge_list Graph; - Graph g(edges, edges + sizeof(edges) / sizeof(E)); - - std::vector distance(N, std::numeric_limits::max()); - std::vector parent(N, -1); - - distance[z] = 0; - parent[z] = z; - bool r = boost::bellman_ford_shortest_paths - (g, int(N), - boost::weight_map(weight). - distance_map(&distance[0]). - predecessor_map(&parent[0])); - - if (r) - for (int i = 0; i < N; ++i) - std::cout << name[i] << ": " << distance[i] - << " " << name[parent[i]] << std::endl; - else - std::cout << "negative cycle" << std::endl; - - return 0; -} diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index 4264a6d2..482d5a28 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -84,7 +84,7 @@ main() { typedef adjacency_list < listS, vecS, directedS, property < vertex_name_t, char >, - property < edge_weight_t, double >>graph_t; + property < edge_weight_t, double > > graph_t; graph_t g; property_map < graph_t, vertex_name_t >::type name_map = diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index 2116535e..e90ab902 100644 --- a/example/bfs_neighbor.cpp +++ b/example/bfs_neighbor.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include /* @@ -142,7 +142,7 @@ int main(int , char* []) p[s] = s; boost::neighbor_breadth_first_search (G, s, - boost::visitor(boost::make_bfs_visitor + boost::visitor(boost::make_neighbor_bfs_visitor (std::make_pair(boost::record_distances(d, boost::on_tree_edge()), boost::record_predecessors(&p[0], boost::on_tree_edge()))))); diff --git a/example/binary-method-problem.cpp b/example/binary-method-problem.cpp deleted file mode 100644 index e4492895..00000000 --- a/example/binary-method-problem.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//======================================================================= -// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, -// -// This file is part of the Boost Graph Library -// -// You should have received a copy of the License Agreement for the -// Boost Graph Library along with the software; see the file LICENSE. -// If not, contact Office of Research, Indiana University, -// Bloomington, IN 47405. -// -// Permission to modify the code and to distribute the code is -// granted, provided the text of this NOTICE is retained, a notice if -// the code was modified is included with the above COPYRIGHT NOTICE -// and with the COPYRIGHT NOTICE in the LICENSE file, and that the -// LICENSE file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= -#include -#include - -class Point -{ -public: - virtual bool equal(const Point * p) const = 0; -}; - -class ColorPoint:public Point -{ -public: - ColorPoint(float x, float y, std::string c):x(x), y(y), color(c) - { - } - virtual bool equal(const ColorPoint * p) const - { - return color == p->color && x == p->x && y == p->y; - } -protected: - float x, y; - std::string color; -}; - -class ColorPoint2:public Point -{ -public: - ColorPoint2(float x, float y, std::string s):x(x), y(y), color(s) - { - } - virtual bool equal(const Point * p) const - { - const ColorPoint2 *cp = dynamic_cast < const ColorPoint2 * >(p); - return color == cp->color && x == cp->x && y == cp->y; - } -protected: - float x, y; - std::string color; -}; - -void -print_equal(const Point * a, const Point * b) -{ - std::cout << std::boolalpha << a->equal(b) << std::endl; -} - -template < typename PointType > void -print_equal2(const PointType * a, const PointType * b) -{ - std::cout << std::boolalpha << a->equal(b) << std::endl; -} - - -int -main() -{ - Point *p = new ColorPoint2(0.0, 0.0, "blue"); - Point *q = new ColorPoint2(0.0, 0.0, "green"); - print_equal(p, q); - ColorPoint *a = new ColorPoint(0.0, 0.0, "blue"); - ColorPoint *b = new ColorPoint(0.0, 0.0, "green"); - print_equal2(a, b); - - - return 0; -} diff --git a/example/copy-example.cpp b/example/copy-example.cpp index c524ca0b..b4a4ebef 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -33,7 +33,7 @@ main() using namespace boost; typedef int weight_t; typedef adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, char >>graph_t; + property < vertex_name_t, char > > graph_t; enum { a, b, c, d, e, f, g, N }; diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index b93eeda8..158663a8 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -35,7 +35,7 @@ int main(int, char *[]) { typedef adjacency_list < listS, vecS, directedS, - no_property, property < edge_weight_t, int >>graph_t; + no_property, property < edge_weight_t, int > > graph_t; typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor; typedef std::pair < int, int >Edge; diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 837d6659..216b31cd 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -80,7 +80,7 @@ namespace boost typedef adjacency_list < vecS, vecS, directedS, no_property, property < edge_capacity_t, degree_size_type, property < edge_residual_capacity_t, degree_size_type, - property < edge_reverse_t, edge_descriptor > >>>FlowGraph; + property < edge_reverse_t, edge_descriptor > > > > FlowGraph; vertex_descriptor u, v, p, k; edge_descriptor e1, e2; diff --git a/example/edmunds-karp-eg.cpp b/example/edmunds-karp-eg.cpp index 288f2cbf..fbfe9107 100644 --- a/example/edmunds-karp-eg.cpp +++ b/example/edmunds-karp-eg.cpp @@ -39,7 +39,7 @@ main() property < vertex_name_t, std::string >, property < edge_capacity_t, long, property < edge_residual_capacity_t, long, - property < edge_reverse_t, Traits::edge_descriptor > >>>Graph; + property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; Graph g; diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index edaff72a..ef38438f 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -30,7 +30,7 @@ main() { using namespace boost; typedef adjacency_list < vecS, vecS, undirectedS, - no_property, property < edge_weight_t, int >>Graph; + no_property, property < edge_weight_t, int > > Graph; typedef graph_traits < Graph >::edge_descriptor Edge; typedef graph_traits < Graph >::vertex_descriptor Vertex; typedef std::pair < int, int >E; diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index bd10c2a1..e538da45 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -35,7 +35,7 @@ main() read_graphviz("figs/telephone-network.dot", g_dot); typedef adjacency_list < vecS, vecS, undirectedS, no_property, - property < edge_weight_t, int >>Graph; + 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); diff --git a/example/lic.cpp b/example/lic.cpp deleted file mode 100644 index 9c311ae8..00000000 --- a/example/lic.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//======================================================================= -// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, -// -// This file is part of the Boost Graph Library -// -// You should have received a copy of the License Agreement for the -// Boost Graph Library along with the software; see the file LICENSE. -// If not, contact Office of Research, Indiana University, -// Bloomington, IN 47405. -// -// Permission to modify the code and to distribute the code is -// granted, provided the text of this NOTICE is retained, a notice if -// the code was modified is included with the above COPYRIGHT NOTICE -// and with the COPYRIGHT NOTICE in the LICENSE file, and that the -// LICENSE file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= -//======================================================================= -// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, -// -// This file is part of the Boost Graph Library -// -// You should have received a copy of the License Agreement for the -// Boost Graph Library along with the software; see the file LICENSE. -// If not, contact Office of Research, Indiana University, -// Bloomington, IN 47405. -// -// Permission to modify the code and to distribute the code is -// granted, provided the text of this NOTICE is retained, a notice if -// the code was modified is included with the above COPYRIGHT NOTICE -// and with the COPYRIGHT NOTICE in the LICENSE file, and that the -// LICENSE file is distributed with the modified code. -// -// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. -// By way of example, but not limitation, Licensor MAKES NO -// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY -// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS -// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS -// OR OTHER RIGHTS. -//======================================================================= diff --git a/example/makefile-dependencies.dat b/example/makefile-dependencies.dat new file mode 100644 index 00000000..8772cefb --- /dev/null +++ b/example/makefile-dependencies.dat @@ -0,0 +1,20 @@ +15 +0 5 +0 7 +0 11 +1 5 +1 11 +2 5 +2 9 +2 11 +3 7 +4 5 +5 13 +6 7 +7 13 +8 9 +9 12 +10 11 +11 12 +12 14 +13 12 diff --git a/example/makefile-target-names.dat b/example/makefile-target-names.dat new file mode 100644 index 00000000..166cbb0e --- /dev/null +++ b/example/makefile-target-names.dat @@ -0,0 +1,15 @@ +dax.h +yow.h +boz.h +zow.h +bar.cpp +bar.o +foo.cpp +foo.o +zig.cpp +zig.o +zag.cpp +zag.o +libzigzag.a +libfoobar.a +killerapp diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index ca89aa15..76d878f8 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -53,28 +53,16 @@ typedef adjacency_list < listS, // Store out-edges of each vertex in a std::list listS, // Store vertex set in a std::list directedS, // The file dependency graph is directed // vertex properties - property < vertex_name_t, - std::string, - property < - vertex_compile_cost_t, float, - property < - vertex_distance_t, float, - property < - vertex_color_t, -default_color_type > >>>, + property < vertex_name_t, std::string, + property < vertex_compile_cost_t, float, + property < vertex_distance_t, float, + property < vertex_color_t, default_color_type > > > >, // an edge property - property < -edge_weight_t, float >> + property < edge_weight_t, float > > file_dep_graph2; -typedef - graph_traits < - file_dep_graph2 >::vertex_descriptor - vertex_t; -typedef - graph_traits < - file_dep_graph2 >::edge_descriptor - edge_t; +typedef graph_traits::vertex_descriptor vertex_t; +typedef graph_traits::edge_descriptor edge_t; template < typename Graph, typename ColorMap, typename Visitor > void @@ -82,21 +70,11 @@ dfs_v2(const Graph & g, typename graph_traits < Graph >::vertex_descriptor u, ColorMap color, Visitor vis) { - typedef typename - property_traits < - ColorMap >::value_type - color_type; - typedef - color_traits < - color_type > - ColorT; + typedef typename property_traits < ColorMap >::value_type color_type; + typedef color_traits < color_type > ColorT; color[u] = ColorT::gray(); vis.discover_vertex(u, g); - typename - graph_traits < - Graph >::out_edge_iterator - ei, - ei_end; + typename graph_traits < Graph >::out_edge_iterator ei, ei_end; for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) if (color[target(*ei, g)] == ColorT::white()) { vis.tree_edge(*ei, g); @@ -139,9 +117,7 @@ template < typename OutputIterator > struct topo_visitor: topo_order(order) { } - template < - typename - Graph > void + template < typename Graph > void finish_vertex(typename graph_traits < Graph >::vertex_descriptor u, const Graph &) { diff --git a/example/prim-example.cpp b/example/prim-example.cpp index 4126d31e..1087f85d 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -30,7 +30,7 @@ main() { using namespace boost; typedef adjacency_list < vecS, vecS, undirectedS, - property < vertex_distance_t, int, property < edge_weight_t, int >>>Graph; + property, property < edge_weight_t, int > > Graph; typedef std::pair < int, int >E; const int num_nodes = 5; E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(1, 4), E(2, 1), E(2, 3), @@ -39,16 +39,15 @@ main() int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1 }; Graph g(num_nodes, edges, edges + sizeof(edges) / sizeof(E), weights); std::vector < graph_traits < Graph >::vertex_descriptor > - p(num_vertices(G)); + p(num_vertices(g)); prim_minimum_spanning_tree(g, &p[0]); - std::vector < Graph::vertex_descriptor >::iterator i; - for (i = p.begin(); i != p.end(); ++i) - cout << "parent[" << i - p.begin() - << "] = " << identity_property_map()[*i] << endl; - else - cout << "parent[" << i - p.begin() << "] = no parent" << endl; + for (std::size_t i = 0; i != p.size(); ++i) + if (p[i] != i) + std::cout << "parent[" << i << "] = " << p[i] << std::endl; + else + std::cout << "parent[" << i << "] = no parent" << std::endl; return EXIT_SUCCESS; } diff --git a/example/target-compile-costs.dat b/example/target-compile-costs.dat new file mode 100644 index 00000000..cc145357 --- /dev/null +++ b/example/target-compile-costs.dat @@ -0,0 +1,15 @@ +0.0 +0.0 +0.0 +0.0 +0.0 +1.5 +0.0 +2.8 +0.0 +3.6 +0.0 +8.7 +1.1 +1.5 +2.1 diff --git a/include/boost/graph/dag_shortest_paths.hpp b/include/boost/graph/dag_shortest_paths.hpp index 641d3e15..8fb60b65 100644 --- a/include/boost/graph/dag_shortest_paths.hpp +++ b/include/boost/graph/dag_shortest_paths.hpp @@ -23,7 +23,7 @@ namespace boost { DistanceMap distance, WeightMap weight, ColorMap color, PredecessorMap pred, DijkstraVisitor vis, Compare compare, Combine combine, - DistInf inf_gen, DistZero zero) + DistInf inf, DistZero zero) { typedef typename graph_traits::vertex_descriptor Vertex; std::vector rev_topo_order; @@ -32,11 +32,11 @@ namespace boost { typename graph_traits::vertex_iterator ui, ui_end; for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { - put(distance, *ui, inf_gen()); + put(distance, *ui, inf); put(pred, *ui, *ui); } - put(distance, s, zero()); + put(distance, s, zero); vis.discover_vertex(s, g); std::vector::reverse_iterator i; for (i = rev_topo_order.rbegin(); i != rev_topo_order.rend(); ++i) { @@ -78,9 +78,9 @@ namespace boost { choose_param(get_param(params, distance_compare_t()), std::less()), choose_param(get_param(params, distance_combine_t()), std::plus()), choose_param(get_param(params, distance_inf_t()), - generate_infinity()), + std::numeric_limits::max()), choose_param(get_param(params, distance_zero_t()), - generate_zero())); + D())); } // Handle DistanceMap and ColorMap defaults