Boost logo

Boost Users :

From: Jeremie (njphoto21_at_[hidden])
Date: 2003-08-01 04:45:19


Hi!
 
I get a graph from graphviz data. I would like to pick up one node and
compute all the distance(number of edge) from this node to the others. My
graph is undirected and unvaluated.
 
I have wrote a function but I get wrong results:
The graph:
0 <--> 1
1 <--> 0 2
2 <--> 1 3 4 5
3 <--> 2
4 <--> 2
5 <--> 2 6 7
6 <--> 5
7 <--> 5
the distance from 0:
2 3 4 3 3 5 4 4
parent[0] = 1
parent[1] = 2
parent[2] = 5
parent[3] = 2
parent[4] = 2
parent[5] = 7
parent[6] = 5
parent[7] = 5
 
Here is my code:
        std::vector<Vertex> p(boost::num_vertices(g));
        boost::graph_traits<GraphvizGraph>::vertices_size_type
d[num_vertices(g)];
         
        std::fill_n(d, num_vertices (g), 0);
        breadth_first_search (g, u, visitor(make_bfs_visitor
(std::make_pair(record_predecessors(&p[0],on_examine_edge()),record_distanc=
es(&d[0],on_examine_edge()))))
        );
 
do you see something wrong?
 
regards
 
/Jérémie
 
 
 
 
 


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net