Boost logo

Boost Users :

From: sashan (sashang_at_[hidden])
Date: 2003-08-08 23:04:22


I'd like to use the graph library to support connections between
different types of objects.
To do this I've created a class GraphNode that forms the base class for
various other objects
that can become vertices of the graph. I've tried the following.

int main(int,char*[])
{
     //these two classes Translate and Mesh inherit from GraphNode
    Translate* pT = new Translate;
    Mesh* pM = new Mesh;
      
    // create a typedef for the Graph type
    typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;

    const int num_vertices = 2;
   
    // writing out the edges in the graph
    typedef std::pair<GraphNode*, GraphNode*> GraphEdge;
    GraphEdge edge_array[] =
    { GraphEdge(pT,pM) };
    const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]);

    // declare a graph object
    Graph g(num_vertices);

    // add the edges to the graph object
    for (int i = 0; i < num_edges; ++i)
        add_edge(edge_array[i].first, edge_array[i].second, g);
   
        return 0;
}

but get the following error message related to the fact that it can't choose a suitable overloaded add_edge function. If I replace the types in the vertex with an int it compiles happily. I'm using Boost 1.30.0

e:\Code\Edge\Console\Console.cpp(42) : error C2665: 'boost::add_edge' : none of the 2 overloads can convert parameter 1 from type 'GraphNode *'
        e:\Code\boost\boost\graph\detail\adjacency_list.hpp(1211): could be 'std::pair<_Ty1,_Ty2> boost::add_edge<boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config>(boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_descriptor,boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_descriptor,boost::bidirectional_graph_helper_with_property<Config> &)'
        with
        [
            _Ty1=boost::adj_list_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::config,boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::DirectedHelper>::edge_descriptor,
            _Ty2=bool,
            Graph=boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,
            VertexListS=boost::vecS,
            OutEdgeListS=boost::vecS,
            DirectedS=boost::bidirectionalS,
            VertexProperty=boost::no_property,
            EdgeProperty=boost::no_property,
            GraphProperty=boost::no_property,
            EdgeListS=boost::listS,
            Config=boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::config
        ]
        e:\Code\boost\boost\graph\detail\adjacency_list.hpp(1941): or 'std::pair<_Ty1,_Ty2> boost::add_edge<Graph,boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config,boost
::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::DirectedHelper>(boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_descriptor,boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_descriptor,boost::vec_adj_list_impl<Graph,Config,Base> &)'
        with
        [
            _Ty1=boost::adj_list_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::config,boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::DirectedHelper>::edge_descriptor,
            _Ty2=bool,
            Graph=boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,
            VertexListS=boost::vecS,
            OutEdgeListS=boost::vecS,
            DirectedS=boost::bidirectionalS,
            VertexProperty=boost::no_property,
            EdgeProperty=boost::no_property,
            GraphProperty=boost::no_property,
            EdgeListS=boost::listS,
            Config=boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::config,
            Base=boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS>,boost::vecS,boost::vecS,boost::bidirectionalS,boost::no_property,boost::no_property,boost::no_property,boost::listS>::DirectedHelper
        ]
        while trying to match the argument list '(GraphNode *, GraphNode *, Graph)'
        e:\Code\boost\boost\iterator_adaptors.hpp(1409) : see reference to class template instantiation 'boost::filter_iterator_generator<Predicate,Iterator,Value,Reference,Pointer,Category,Distance>' being compiled


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