Boost logo

Boost :

From: Brian Kallehauge (bk_at_[hidden])
Date: 2007-11-07 02:38:14


I was wondering if it is possible to define an index property for each
vertex in the graph and then use that index to get the vertex_descriptor of
the vertex?

 

I have made an example (see below) where I have tried to show what I would
like to do. The graph should use listS for edges and vertices.

 

Thanks,

Brian Kallehauge

 

 

#include <boost/graph/adjacency_list.hpp>

#include <utility>

 

int main (int argc, char *argv[])

{

           using namespace std;

           using namespace boost;

 

           typedef adjacency_list_traits<listS, listS,
directedS>::vertex_descriptor VertexDescriptor;

           typedef adjacency_list_traits<listS, listS,
directedS>::edge_descriptor EdgeDescriptor;

           typedef pair<EdgeDescriptor, bool> EdgeDescriptorBool;

           typedef property<vertex_index_t, int> VertexProperties;

           typedef adjacency_list<listS, listS, directedS, VertexProperties>
Graph;

 

           Graph graph;

 

           VertexDescriptor v;

 

           // Add two vertices with external unique id 1001 and 1002,
respectively

           v = add_vertex(graph);

           put(vertex_index, graph, v, 1001);

 

           v = add_vertex(graph);

           put(vertex_index, graph, v, 1002);

 

           // How do I add an edge between the two vertices with external
unique

           // vertex index 1001 and 1002 by referring to their unique ids
1001 and 1002?

           EdgeDescriptorBool eb;

           eb = add_edge(1001, 1002, graph); // error C2664:
'boost::add_edge' : cannot convert parameter 1 from 'int' to 'void *'

 

           return 0;

}

 

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk