Error in accessing label of an edge, urgently need help.
Hello, I want to put edge label but facing an error. Please share any better idea. Thanks in advance. YASIN ======================= My graph is: namespace boost { struct computable_object_t { typedef vertex_property_tag kind; }; } typedef boost::property<boost::vertex_index_t, unsigned int, boost::property<boost::computable_object_t, plComputableObject*> > slVertexProperty; typedef boost::property<boost::edge_weight_t, slScoreValueType, boost::property<boost::edge_name_t, std::string>> slEdgeProperty; typedef boost::adjacency_list<boost::vecS, boost::listS, boost::bidirectionalS, slVertexProperty, slEdgeProperty> slGraph; slGraph graph; .... ... //Now i want to add edge name boost::property_map<slGraph, edge_name_t>::type labelmap = get(edge_name, graph); for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei){ string label = "unknown"; put(labelmap, *ei, label); cout<<"\nUndirected s: "<<vertex_id[source(*ei, graph)] <<" T: "<<vertex_id[target(*ei, graph)]<<" LABEL: "<< get(labelmap,*ei); } ////////////But it gives me an error//////////////// E:\ProBT22\boost_1_46_1\boost/property_map/property_map.hpp(361): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) 1> E:\ProBT22\boost_1_46_1\boost/pending/detail/property.hpp(21): could be 'boost::detail::error_property_not_found &boost::detail::error_property_not_found::operator =(const boost::detail::error_property_not_found &)' 1> while trying to match the argument list '(boost::detail::error_property_not_found, const std::string)' 1> MMHC\ResultAnalysis.cpp(558) : see reference to function template instantiation 'void boost::put<boost::adj_list_edge_property_map<Directed,Value,Ref,Vertex,Property,Tag>,Ref,boost::detail::edge_desc_impl<Directed,Vertex>,std::string>(const boost::put_get_helper<Reference,LvaluePropertyMap> &,K,const V &)' being compiled 1> with 1> [ 1> Directed=boost::bidirectional_tag, 1> Value=boost::detail::error_property_not_found, 1> Ref=boost::detail::error_property_not_found &, 1> Vertex=void *, 1> Property=boost::property<boost::edge_weight_t,slScoreValueType>, 1> Tag=boost::edge_name_t, 1> Reference=boost::detail::error_property_not_found &, 1> LvaluePropertyMap=boost::adj_list_edge_property_map<boost::bidirectional_tag,boost::detail::error_property_not_found,boost::detail::error_property_not_found &,void *,boost::property<boost::edge_weight_t,slScoreValueType>,boost::edge_name_t>, 1> K=boost::detail::edge_desc_impl<boost::bidirectional_tag,void *>, 1> V=std::string 1> ]
On Wed, 14 Dec 2011, Amanullah Yasin wrote:
Hello,
I want to put edge label but facing an error. Please share any better idea. Thanks in advance.
BTW, you shouldn't add things to the boost namespace; property names don't need to be in that namespace. Anyway, the code worked for me with GCC 4.6. Here's the full test program I used: #include <boost/graph/properties.hpp> #include <boost/graph/adjacency_list.hpp> #include <string> #include <iostream> struct plComputableObject; struct slScoreValueType {}; namespace boost { struct computable_object_t { typedef vertex_property_tag kind; }; } typedef boost::property<boost::vertex_index_t, unsigned int, boost::property<boost::computable_object_t, plComputableObject*> > slVertexProperty; typedef boost::property<boost::edge_weight_t, slScoreValueType, boost::property<boost::edge_name_t, std::string> > slEdgeProperty; typedef boost::adjacency_list<boost::vecS, boost::listS, boost::bidirectionalS, slVertexProperty, slEdgeProperty> slGraph; int main(int, char**) { using namespace boost; slGraph graph; //Now i want to add edge name boost::property_map<slGraph, edge_name_t>::type labelmap = get(edge_name, graph); boost::graph_traits<slGraph>::edge_iterator ei, ei_end; for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei){ std::string label = "unknown"; put(labelmap, *ei, label); std::cout<<"\nUndirected s: "<<source(*ei, graph) <<" T: "<<target(*ei, graph)<<" LABEL: "<< get(labelmap,*ei); } } -- Jeremiah Willcock
Thanks it works On Wed, Dec 14, 2011 at 5:35 PM, Jeremiah Willcock <jewillco@osl.iu.edu>wrote:
On Wed, 14 Dec 2011, Amanullah Yasin wrote:
Hello,
I want to put edge label but facing an error. Please share any better idea. Thanks in advance.
BTW, you shouldn't add things to the boost namespace; property names don't need to be in that namespace. Anyway, the code worked for me with GCC 4.6. Here's the full test program I used:
#include <boost/graph/properties.hpp> #include <boost/graph/adjacency_list.**hpp> #include <string> #include <iostream>
struct plComputableObject; struct slScoreValueType {};
namespace boost { struct computable_object_t { typedef vertex_property_tag kind; }; }
typedef boost::property<boost::vertex_**index_t, unsigned int, boost::property<boost::**computable_object_t, plComputableObject*> > slVertexProperty;
typedef boost::property<boost::edge_**weight_t, slScoreValueType, boost::property<boost::edge_**name_t, std::string> > slEdgeProperty;
typedef boost::adjacency_list<boost::**vecS, boost::listS, boost::bidirectionalS, slVertexProperty, slEdgeProperty> slGraph;
int main(int, char**) { using namespace boost; slGraph graph;
//Now i want to add edge name boost::property_map<slGraph, edge_name_t>::type labelmap = get(edge_name, graph);
boost::graph_traits<slGraph>::**edge_iterator ei, ei_end;
for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei){
std::string label = "unknown"; put(labelmap, *ei, label); std::cout<<"\nUndirected s: "<<source(*ei, graph) <<" T: "<<target(*ei, graph)<<" LABEL: "<< get(labelmap,*ei); } }
-- Jeremiah Willcock
participants (2)
-
Amanullah Yasin
-
Jeremiah Willcock