|
Boost Users : |
From: Dominik Heide (dheide_at_[hidden])
Date: 2007-06-04 12:11:46
Hi there,
I want to delete a vertex from a graph and later reinsert it again. I did this
by removing all edges from that vertex and later adding the edges again. But
the behavior of the program quite strange.
First, I use a undirected adjacancy list
typedef adjacency_list<vecS, vecS, undirectedS, no_property, no_property>
Graph;
When, use
Graph g, gs;
// set g
typename graph_traits<GraphT>::vertex_iterator vi, ve, vii, vei;
typename graph_traits<GraphT>::out_edge_iterator out_i, out_end, tmp;
for( tie(vi, ve) = vertices(g); vi != ve; vi++)
{
gs = g;
clear_vertex( *vi, g)
// some code
g = gs;
}
everything is fine. I don't want to save the whole graph since I only delete a
couple of edges. Therefore, I did
vector<typename graph_traits<GraphT>::vertex_descriptor> deletedEdges;
typename vector<typename graph_traits<GraphT>::vertex_descriptor>::iterator
dei;
typename graph_traits<GraphT>::vertex_iterator vi, ve, vii, vei;
typename graph_traits<GraphT>::out_edge_iterator out_i, out_end, tmp;
...
for( tie(vi, ve) = vertices(g); vi != ve; vi++)
{
for( tie( out_i, out_end ) = out_edges( *vi, g); out_i != out_end; out_i++)
{
deletedEdges.push_back(target(*out_i, g));
}
clear_vertex( *vi, g)
// some code
for(dei = deletedEdges.begin(); dei < deletedEdges.end(); ++dei)
{
add_edge( *vi, *dei, g);
}
}
This code does not restore the graph completely. Although it looks the same
the shortest paths are different to the ones with the above code.
Is there something about clear_vertex() I don't know and therefore don't
restore corectly?
Any help appreachiated, Thank you, Dominik
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