Bonsoir, je voulais savoir comment faire pour récupérer les arêtes d'un graphes et les mettre dans une fille d'attente en utilisant BOOST et queue c++.
voila une partie du code:
les structures
Sachant que le graphe se trouve au début d'un vecteur voila ce que j'ai fais
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
37 // vertex struct VertexProperties { int id; int label; VertexProperties(unsigned i=0, unsigned l=0) : id(i), label(l) {} }; // edge struct EdgeProperties { unsigned id; unsigned label; EdgeProperties(unsigned i=0, unsigned l=0) : id(i), label(l) {} }; // Graph struct GraphProperties { unsigned id; unsigned label; GraphProperties(unsigned i=0, unsigned l=0) : id(i), label(l) {} }; // adjency list typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperties, EdgeProperties, GraphProperties> Graph; // descriptors typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t; typedef std::pair<boost::graph_traits<Graph>::edge_descriptor, bool> edge_t; // iterators typedef graph_traits<Graph>::vertex_iterator vertex_iter; typedef graph_traits<Graph>::edge_iterator edge_iter;
Si c'est juste, comment afficher les informations de chaque arête svp!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 std::queue<edge_iter> myqueue; typedef std::pair<edge_iter, edge_iter> edge_pair; if (!dataG.empty()) { Graph const& gr = dataG.front(); // firslt graph in G_list edge_pair epg; for (epg = edges(gr); epg.first != epg.second; ++epg.first) //ep edge number { myqueue.push(epg.first); } }
j'ai essayé ça mais ça marche pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 while (!myqueue.empty()) { std::cout << ' ' << myqueue.front().label; myqueue.pop(); }
Partager