|
Boost Users : |
From: Michael Kettner (kettner_at_[hidden])
Date: 2002-07-12 12:36:21
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Jeremy,
thanks for your quick reply.
What I do is the following: I wrote my own class representing nodes (class
myNodeClass). Now I'm creating nodes in a graph, mapping each resulting
vertex index to the associated myNode-object in a std::map. I hope the
following code fragment is enough to give you an idea:
class myNodeClass;
typedef boost::adjacency_list<boost::vecS,boost::vecS,
boost::bidirectionalS,boost::no_property,boost::no_property> tGraph;
typedef typename boost::graph_traits < tGraph >::vertex_descriptor tNode;
std::map<myNodeClass*, tNode> mapNode;
tGraph myGraph;
myNodeClass* myNode = new myNodeClass();
mapNode[myNode] = boost::add_vertex( myGraph );
myNodeClass* myNode2 = new myNodeClass();
mapNode[myNode2] = boost::add_vertex( myGraph );
boost::clear_vertex( mapNode[myNode], myGraph );
boost::remove_vertex( mapNode[myNode], myGraph );
mapNode.erase(myNode);
And this causes trouble: the result of
mapNode[myNode2]
now is no longer valid. Any hint how I can avoid this?
And another question: I tried to run boost::dijkstra_shortest_paths on myGraph
with "listS" as VertexList template parameter, but the code fails to compile.
When using "vecS" instead, everything works fine. Any idea?
Best regards,
Michael
On Friday 12 July 2002 17:54, Jeremy Siek wrote:
> Hi Michael,
>
> You can't add your own vertex_index property to an adjacency_list with
> VertexList=vecS. The adjacency_list will just ignore it if you do. You can
> if VertexList=listS, and example/adjacency_list.cpp is an example of this.
>
> Also, you can add properties with names other than vertex_index_t to
> adjacency_list with VertexList=vecS. For example, you could add your own
> vertex_id_t property. However, this would *not* keep the vertex
> descriptors from being invalidated, it would just give you a vertex_id_t
> property that is stable.
>
> I'm not sure if the above helps... I don't know the details of what you
> are trying to do, but feel free to ask further questions.
>
> Cheers,
> Jeremy
>
>
> On Fri, 12 Jul 2002, Michael Kettner wrote:
> kettne> Hi,
> kettne>
> kettne> can someone give an example how to "not use the built-in vertex
> index, and kettne> instead use a property to add my own vertex index
> property" (see page 223 kettne> BGL-book) for an adjacency_list?
> kettne> My problem is that I'm using the vecS selector for the VertexList
> template kettne> parameter and I need to remove vertices from my graph (but
> not frequently). kettne> Every time I do this, my vertex descriptors are
> invalidated (as described in kettne> the book). I need a solution so that I
> can remove some vertices and all my kettne> vertex descriptors remain
> valid.
> kettne>
> kettne> Thanks in advance,
> kettne>
> kettne> Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9LxOVkCdGnb0kVFMRAsIjAJ9CJGpmbc6lpuoEhGgeznxdUunndwCfRnh4
wbjiVESZ3HwVrNkhJ4Gvf48=
=0S8n
-----END PGP SIGNATURE-----
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