|
Boost Users : |
Subject: [Boost-users] [Graph] Issue with remove_edge function and subgraphs
From: Marcus Fontaine (mfontai5_at_[hidden])
Date: 2010-05-09 16:57:14
According to the online documentation,
http://www.boost.org/doc/libs/1_38_0/libs/graph/doc/subgraph.html
The remove_edge function when used on a subgraph should,
"Remove the edge (u,v) from the subgraph and from all of the ancestors
of g in the subgraph tree."
In the example I have here, it just seems to remove the edge between
vertices 0 and 2 from the ancestor and not the subgraph.
Any advice or explanation would be greatly appreciated.
#include <iostream>
#include <vector>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/subgraph.hpp>
using namespace std;
using namespace boost;
typedef subgraph< adjacency_list<vecS, vecS, undirectedS,
property<vertex_index_t, int>, property<edge_index_t, int> > > Graph;
int main()
{
Graph G;
add_edge(0, 1, G);
add_edge(0, 2, G);
add_edge(1, 2, G);
add_edge(2, 3, G);
add_edge(0, 3, G);
Graph subG = G.create_subgraph();
add_vertex(0, subG);
add_vertex(1, subG);
add_vertex(2, subG);
add_vertex(3, subG);
remove_edge(subG.global_to_local(2), subG.global_to_local(0) ,subG);
graph_traits<Graph>::adjacency_iterator ai;
graph_traits<Graph>::adjacency_iterator ai_end;
cout << "Adjacent vertices of 0 in G: ";
//Should be 1 3, and correctly is so.
for(tie(ai, ai_end) = adjacent_vertices(0, G); ai != ai_end; ++ai)
{
cout << *ai << " ";
}
cout << endl;
cout << "Adjacent vertices of 0 in subG: ";
//Should be 1 3, but gives 1 2 3.
for(tie(ai, ai_end) = adjacent_vertices(subG.global_to_local(0),
subG); ai != ai_end; ++ai)
{
cout << subG.local_to_global(*ai) << " ";
}
cout << endl;
return 0;
}
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