Boost logo

Boost Users :

Subject: [Boost-users] [BGL] Error C2679 when inserting edge property to subgraph
From: Nicholas Mario Wardhana (mario.wardhana_at_[hidden])
Date: 2013-03-22 12:41:30


Hi all,

Could somebody tell me how to add a bundled edge property for subgraph, please?

The code, based on [1], is as follows.

// code starts

#include <boost/config.hpp>
#include <boost/graph/subgraph.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>

using namespace std;
using namespace boost;

struct VertexProperty {
    int intValue;
};

struct EdgeProperty {
    std::size_t biconnected_component;
    int intValue;
};

typedef adjacency_list<vecS, vecS, undirectedS, VertexProperty,
    property<edge_index_t, int, EdgeProperty> > PlainGraph;
typedef subgraph<PlainGraph> Graph;

int main(int argc, char* argv[])
{
    PlainGraph g1;
    Graph g(2);

    VertexProperty v0;
    v0.intValue = 1;
    VertexProperty v1;
    v0.intValue = 1;

    EdgeProperty e;
    e.biconnected_component = 0;
    e.intValue = 0;

    add_edge(0, 1, g);
    put(get(vertex_bundle,g), 0, v0); // OK
    put(get(vertex_bundle,g), 1, v1); // OK
    put(get(edge_bundle,g), 0, e); // error here

    return 0;
}

// code ends

The error is as follows:

// error starts

1>D:\API\boost_1_53_0\boost/property_map/property_map.hpp(361): error
C2679: binary '[' : no operator found which takes a right-hand operand
of type 'int' (or there is no acceptable conversion)
1> D:\API\boost_1_53_0\boost/graph/subgraph.hpp(797): could
be 'EdgeProperty
&boost::subgraph_global_property_map<GraphPtr,PropertyMap,Tag>::operator
[](boost::detail::edge_desc_impl<Directed,Vertex>) const'
1> with
1> [
1> GraphPtr=boost::subgraph<PlainGraph> ,
1>
PropertyMap=boost::adj_list_edge_property_map<boost::undirected_tag,EdgeProperty,EdgeProperty
&,unsigned __int64,boost::property<boost::edge_index_t,int,EdgeProperty>,boost::edge_bundle_t>,
1> Tag=boost::edge_bundle_t,
1> Directed=boost::undirected_tag,
1> Vertex=unsigned __int64
1> ]
1> while trying to match the argument list '(const
boost::subgraph_global_property_map<GraphPtr,PropertyMap,Tag>, int)'
1> with
1> [
1> GraphPtr=boost::subgraph<PlainGraph> ,
1>
PropertyMap=boost::adj_list_edge_property_map<boost::undirected_tag,EdgeProperty,EdgeProperty
&,unsigned __int64,boost::property<boost::edge_index_t,int,EdgeProperty>,boost::edge_bundle_t>,
1> Tag=boost::edge_bundle_t
1> ]
1> main.cpp(74) : see reference to function template
instantiation 'void
boost::put<boost::subgraph_global_property_map<GraphPtr,PropertyMap,Tag>,EdgeProperty&,int,EdgeProperty>(const
boost::put_get_helper<Reference,LvaluePropertyMap> &,K,const V &)'
being compiled
1> with
1> [
1> GraphPtr=boost::subgraph<PlainGraph> ,
1>
PropertyMap=boost::adj_list_edge_property_map<boost::undirected_tag,EdgeProperty,EdgeProperty
&,unsigned __int64,boost::property<boost::edge_index_t,int,EdgeProperty>,boost::edge_bundle_t>,
1> Tag=boost::edge_bundle_t,
1> Reference=EdgeProperty &,
1>
LvaluePropertyMap=boost::subgraph_global_property_map<boost::subgraph<PlainGraph>
,boost::adj_list_edge_property_map<boost::undirected_tag,EdgeProperty,EdgeProperty
&,unsigned __int64,boost::property<boost::edge_index_t,int,EdgeProperty>,boost::edge_bundle_t>,boost::edge_bundle_t>,
1> K=int,
1> V=EdgeProperty
1> ]
1>

// error ends

I found a few other threads [2, 3] about this, but their solutions
don't solve the problem. BTW I use Visual Studio 2010 on Windows 7
64-bit. The Boost version is 1.53.0.

Thank you!

Best regards,
Nicholas Mario Wardhana

References:
[1] http://boost.2283326.n4.nabble.com/BGL-Bundled-Properties-in-subgraphs-td2562420.html
[2] http://stackoverflow.com/questions/7608031/boost-subgraph-and-bundled-properties
[3] https://groups.google.com/forum/?fromgroups=#!topic/boost-list/5EIkKybaUTY


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