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
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 deletedEdges;
typename vector::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