-->http://lists.boost.org/boost-users/2008/03/34808.php
Hello Aaron,
you assumption is corrrect, I used a vecS:
typedef adjacency_list
Hi,
I need some help on the remove_edge, remove_vertex functions. What is wrong with my two functions, removing edges or vertex from a
graph
with a given name in the coressponding property map. pls. see code snippet after calling my function a second time I get a run time error. I did the code as shown under http://www.boost.org/libs/graph/doc/adjacency_list.html but I feel the rebuild of the vectors did not work, any input is welcome
Best
Bernhard
this is the code in the main program:
// ok MyElementList.RemoveVertexByName("vss!",g, VertexNamesMap); // now the run time error ... MyElementList.RemoveVertexByName("vss!s",g, VertexNamesMap);
this is the called sub routine:
/*$
****************************************************************************
** Method Name RemoveVertexByName ()... Parameters std::string AE_Name Return long , Index in Map Description remove vertex with a given name see http://www.boost.org/libs/graph/doc/adjacency_list.html
for troubles
****************************************************************************
****** */ void TElementList::RemoveVertexByName(std::string elementname, TGraph &g, TVertexNameMap &VertexNamesMap) { Tvertex_iter vi, vi_end, next; tie(vi, vi_end) = vertices(g); for (next = vi; vi != vi_end; vi = next) { ++next; if (VertexNamesMap[*vi] == elementname) { remove_vertex(*vi, g); } }
}
Hi Bernhard, Your RemoveVertexByName function will work only if the vertices in your graph are stored in a list, but your email seems to suggest that you have them stored in a vector. If your vertices are stored in a vector, you're not going to be able to remove them in a single loop like this because you'll invalidate the underlying std::vector iterators you're using when you remove vertices. If you are using a list to store your vertices, this code should work as long as VertexNamesMap is populated with all of the vertices in your original graph. Regards, Aaron _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1343 - Release Date: 25.03.2008 19:17 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1343 - Release Date: 25.03.2008 19:17 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.1/1348 - Release Date: 28.03.2008 10:58