[BGL] Error C2679 when inserting edge property to subgraph

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-td256... [2] http://stackoverflow.com/questions/7608031/boost-subgraph-and-bundled-proper... [3] https://groups.google.com/forum/?fromgroups=#!topic/boost-list/5EIkKybaUTY

On Sat, 23 Mar 2013, Nicholas Mario Wardhana wrote:
Hi all,
Could somebody tell me how to add a bundled edge property for subgraph, please?
(snip)
put(get(edge_bundle,g), 0, e); // error here
"0" is not a valid edge descriptor. If you want to store the property on the edge you added earlier, you'll need to keep its edge descriptor (returned from add_edge) and use that as the second argument to put(). -- Jeremiah Willcock

On 23 March 2013 02:54, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
On Sat, 23 Mar 2013, Nicholas Mario Wardhana wrote:
put(get(edge_bundle,g), 0, e); // error here
"0" is not a valid edge descriptor. If you want to store the property on the edge you added earlier, you'll need to keep its edge descriptor (returned from add_edge) and use that as the second argument to put().
-- Jeremiah Willcock
Ah, I didn't realise it. So I changed the code to: std::pair<Graph::edge_descriptor, bool> ed = add_edge(0, 1, g); put(get(edge_bundle,g), ed.first, e); and that solves the problem. Thank you Jeremiah! Best regards, Nicholas Mario Wardhana
participants (2)
-
Jeremiah Willcock
-
Nicholas Mario Wardhana