#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <boost/graph/breadth_first_search.hpp>
#include <fstream>
typedef boost::graph_traits<Polyhedron>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Polyhedron>::vertex_iterator vertex_iterator;
int main(int, char** argv) {
Polyhedron P;
std::ifstream in(argv[1]);
in >> P ;
vertex_iterator vb, ve;
int index = 0;
for(boost::tie(vb,ve)=
vertices(P); vb!=ve; ++vb ){
vertex_descriptor vd = *vb;
vd->id() = index++;
}
std::vector<int> distance(P.size_of_vertices());
vertex_descriptor vd = *vb;
std::cout << "We compute distances to " << vd->point() << std::endl;
boost::breadth_first_search(P,
vd,
visitor(boost::make_bfs_visitor(boost::record_distances(make_iterator_property_map(distance.begin(),
get(boost::vertex_index, P)),
boost::on_tree_edge()))));
for(boost::tie(vb,ve)=
vertices(P); vb!=ve; ++vb ){
vd = *vb;
std::cout << vd->point() << " is " << distance[vd->id()] << " hops away" << std::endl;
}
return 0;
}