1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
typedef adjacency_list<vecS, vecS, undirectedS, int, int> Graph;
Graph _Bgraphe;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
Vertex v1 = add_vertex(_Bgraphe);
Vertex v2 = add_vertex(_Bgraphe);
_Bgraphe[v1] = 12;
_Bgraphe[v2] = 20;
graph_traits<Graph>::vertex_iterator v_it, v_end, debut;
boost::tie(debut,v_end) = vertices(_Bgraphe);
//parcours des neouds
for (v_it=debut;v_it!=v_end;v_it++)
{std::cout<<_Bgraphe[*v_it];
}
boost::add_edge(v1, v2, _Bgraphe);
std::cout << "edges(g) = ";
graph_traits<Graph>::edge_iterator ei, ei_end;
for (tie(ei, ei_end) = edges(_Bgraphe); ei != ei_end; ++ei)
{
std::cout<<"source ";
std::cout << boost::source(*ei, _Bgraphe);std::cout << "\n cible ";
std::cout << boost::target(*ei, _Bgraphe); |
Partager