Boost logo

Boost Users :

From: Stephan Diederich (stephan.diederich_at_[hidden])
Date: 2007-08-28 07:39:27


Hi Sam,

On 8/28/07, Sam Peterson <peabodyenator_at_[hidden]> wrote:
> I know that if I use a setS for the edgelist container for an
> adjacency_list class, each edge of my graph will only be added once as
> I build it.
>
> This functionality is very desirable for me, but I've found I can't
> seem to use it with the equally desirable Bundled Property Maps.
> Specifically, this line of code doesn't seem to work:
>
> (*g)[i].paper_id = atoi(row[0]);
>
> g is a pointer to my graph. The exact compiler error with g++ 4.1.1 is:
>
> error: invalid conversion from 'size_t' to 'void*'

An example would be very helpful, as the following compiles fine for
me with boost 1.33.1 and g++ 4.1.2:

Cheers,
Stephan

#include <iostream>
#include <boost/graph/adjacency_list.hpp>

struct Vertex{
};

struct Edge{
        std::size_t paperid;
};

int
main()
{
        using namespace boost;

         typedef adjacency_list<setS, vecS, directedS, Vertex, Edge,
no_property, setS> Graph;
         typedef graph_traits<Graph>::edge_descriptor edge_descriptor;
        typedef graph_traits<Graph>::edge_iterator edge_iterator;
        
        Graph g;
        Graph* p_g = &g;

        std::pair<edge_descriptor, bool> p = add_edge(0,1, g);
        if(p.second){
                g[p.first].paperid = 1;
        } else{
                std::cout << "Could not insert edge" << std::endl;
        }
        edge_iterator it, end;
        for(tie(it, end) = edges(g); it != end; ++it){
                std::cout << (*p_g)[*it].paperid <<std::endl;
        }
        return 0;
}


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