|
Boost Users : |
From: Bernhard Lippmann (bernhard.lippmann_at_[hidden])
Date: 2008-03-28 19:22:46
-->http://lists.boost.org/boost-users/2008/03/34808.php
Hello Aaron,
you assumption is corrrect, I used a vecS:
typedef adjacency_list<listS, vecS, undirectedS,
// Vertex properties
property <vertex_name_t, std::string >,
// Edge properties
property <edge_weight_t, float, property <edge_index_t, std::size_t,
property <edge_name_t, std::string >>>> TGraph;
I may change now to typedef adjacency_list<listS, listS, .....>,
is there any sample code how to add_edges for listS and how to update the
property maps, once I removed a single vertex or more ....
Best
Bernhard
-----Ursprüngliche Nachricht-----
Von: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]]Im Auftrag von Aaron Windsor
Gesendet: Mittwoch, 26. März 2008 14:06
An: boost-users_at_[hidden]
Betreff: Re: [Boost-users] [boost] [Graph] need help on remove_vertex ....
On Sun, Mar 23, 2008 at 6:21 PM, Bernhard Lippmann
wrote:
>
> 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_at_[hidden]
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
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