Boost logo

Boost Users :

Subject: [Boost-users] boost graph adjacency_list delete nodes and vertices
From: Paolo Bolzoni (paolo.bolzoni.brown_at_[hidden])
Date: 2015-09-14 05:58:59


Dear list,

I am using boost graph with vecS both as edge-list and vertex-list and
I need to delete some nodes.

In my case nodes have no incoming or outgoing edges, but I'd like to
understand how to do it in general.

In vectors normally you simply swap the unwanted element with the last
one and pop back.
This way only the last element index is changed, all others are fine.

The generalization of this idea is the base of the "remove erase idiom".

It possible to apply it to adjacency_list (vecS,vecS)?

I need this because I keep vertex index elsewhere, so I'd like to be
able to update only the last one and not all of them.

>From the implementation I get that is possible to swap the vertex you
want to delete with the "last" one and delete it. By last one I mean
the one returned by *(--vertices(g).second)

It is really safe? And how to delete edges, it is possible?

Yours faithfully,
Paolo


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