// Sorry, I simply wanted to keep the bandwith small.
// here is the code, with the modification I made.
// I will appreciate your instructions on how to proceed.
// Regards and thanks
// Luca
//====================================================================
===
// 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
Graph;
Graph G(5);
boost::add_edge(2, 0, G);
boost::add_edge(1, 1, G);
boost::add_edge(3, 1, G);
boost::add_edge(4, 1, G);
boost::add_edge(2, 1, G);
boost::add_edge(3, 2, G);
boost::add_edge(4, 2, G);
boost::add_edge(1, 3, G);
boost::add_edge(4, 3, G);
boost::add_edge(0, 4, G);
boost::add_edge(1, 4, G);
/*
boost::add_edge(0, 2, G);
boost::add_edge(1, 1, G);
boost::add_edge(1, 3, G);
boost::add_edge(1, 4, G);
boost::add_edge(2, 1, G);
boost::add_edge(2, 3, G);
boost::add_edge(2, 4, G);
boost::add_edge(3, 1, G);
boost::add_edge(3, 4, G);
boost::add_edge(4, 0, G);
boost::add_edge(4, 1, G);
*/
typedef Graph::vertex_descriptor Vertex;
Graph G_copy(5);
// Array to store predecessor (parent) of each vertex. This will be
// used as a Decorator (actually, its iterator will be).
std::vector<Vertex> p(boost::num_vertices(G));
// VC++ version of std::vector has no ::pointer, so
// I use ::value_type* instead.
typedef std::vector<Vertex>::value_type* Piter;
// Array to store distances from the source to each vertex . We use
// a built-in array here just for variety. This will also be used as
// a Decorator.
boost::graph_traits<Graph>::vertices_size_type d[5];
std::fill_n(d, 5, 0);
// The source vertex
Vertex s = *(boost::vertices(G).first);
p[s] = s;
boost::breadth_first_search
(G, s,
boost::visitor(boost::make_bfs_visitor
(std::make_pair(boost::record_distances(d, boost::on_tree_edge
()),
std::make_pair
(boost::record_predecessors(&p[0],
boost::on_tree_edge
()),
copy_graph(G_copy, boost::on_examine_edge
())))) ));
boost::print_graph(G);
boost::print_graph(G_copy);
if (boost::num_vertices(G) < 11) {
std::cout << "distances: ";
#ifdef BOOST_OLD_STREAM_ITERATORS
std::copy(d, d + 5, std::ostream_iterator