Can you do something like typedef boost::graph_traits<Graph>::edge_descriptor Edge; Edge e; .... std::set<Edge> edges; edgeSet.insert( e ); I am getting compiler errors that imply that the edge_descriptor does not implement the < operator. Thanks, James
On Thu, May 1, 2008 at 5:29 PM, James Sutherland
Can you do something like
typedef boost::graph_traits<Graph>::edge_descriptor Edge; Edge e; .... std::set<Edge> edges; edgeSet.insert( e );
I am getting compiler errors that imply that the edge_descriptor does not implement the < operator.
Thanks,
I'm experiencing the same issue... I'd like defining an operator< for the specific edge_descriptor I have (i.e., I use boost::vecS for the edge container), but I don't know what kind of type edge_descriptor is? Or maybe, I can safety convert an edge_descriptor to a standard type like 'int'? Regards, -- Johan
On Wed, Mar 11, 2009 at 5:40 PM, Johan Oudinet
On Thu, May 1, 2008 at 5:29 PM, James Sutherland
wrote: Can you do something like
typedef boost::graph_traits<Graph>::edge_descriptor Edge; Edge e; .... std::set<Edge> edges; edgeSet.insert( e );
I am getting compiler errors that imply that the edge_descriptor does not implement the < operator.
Thanks,
I'm experiencing the same issue... I'd like defining an operator< for the specific edge_descriptor I have (i.e., I use boost::vecS for the edge container), but I don't know what kind of type edge_descriptor is?
Or maybe, I can safety convert an edge_descriptor to a standard type like 'int'?
I finally found the implementation of edge_descriptor in boost/graph/detail/edge.hpp Since I found that operator== use get_property method, I defined an operator < that compares results of get_property() I think it works for my graphs. But I have no idea of the limitations of this silly workaround! Hope it will be useful for someone else. Regards, -- Johan
On Wed, Mar 11, 2009 at 1:18 PM, Johan Oudinet
I finally found the implementation of edge_descriptor in boost/graph/detail/edge.hpp Since I found that operator== use get_property method, I defined an operator < that compares results of get_property()
I think it works for my graphs. But I have no idea of the limitations of this silly workaround!
Strangely enough, I use std::set
Hope it will be useful for someone else.
There have been threads in the past where this same solution was posted. I can't remember what the authors said about portability and correctness, but I would search the mailing lists for "edge_descriptor" + "operator". --Michael Fawcett
On Wed, Mar 11, 2009 at 6:30 PM, Michael Fawcett
On Wed, Mar 11, 2009 at 1:18 PM, Johan Oudinet
wrote: I finally found the implementation of edge_descriptor in boost/graph/detail/edge.hpp Since I found that operator== use get_property method, I defined an operator < that compares results of get_property()
I think it works for my graphs. But I have no idea of the limitations of this silly workaround!
Strangely enough, I use std::set
without having to define a less-than operator. Perhaps it has to do with what the vertex and edge storage types are? I use vecS for both. Hope it will be useful for someone else.
There have been threads in the past where this same solution was posted. I can't remember what the authors said about portability and correctness, but I would search the mailing lists for "edge_descriptor" + "operator".
Ok. It's because I use boost 1.34.1 (that is the current version in Ubuntu Intrepid repositories!). I've just checked for in the last Boost version (1.38) and, now, the operator< is defined in the file boost/graph/detail/edge.hpp Since they compare get_property() as I do, I know I can safety do it ;) Thanks Michael for pointing me out that I'm using an old version. Regards, -- Johan
I'm personally using edge descriptors as keys for a map type and it works (I use version 1.38). Vertex descriptors also work with boost::unordered_map, but the sad thing is that edge descriptors don't work with it, and it'd be nice. Just one thing: When you say you use vecS for edge storage type, you mean OutEdgeList or EdgeList? I ask that cause in known problems it says that, for the moment, only listS is guarranted to work for EdgeList (the last template parameter of adjacency_list). In fact I tried to use vecS for it and I had serious problems. With listS everything works all right. Of course, for OutEdgeList, vecS is fine :) Cheers, Juan
Strangely enough, I use std::set
without having to define a less-than operator. Perhaps it has to do with what the vertex and edge storage types are? I use vecS for both.
On Sun, Mar 15, 2009 at 6:46 PM, Juan Antonio Farré Basurte
When you say you use vecS for edge storage type, you mean OutEdgeList or EdgeList? I ask that cause in known problems it says that, for the moment, only listS is guarranted to work for EdgeList (the last template parameter of adjacency_list). In fact I tried to use vecS for it and I had serious problems. With listS everything works all right. Of course, for OutEdgeList, vecS is fine :)
I meant for OutEdgeList, however I went back and tried vecS for EdgeList as well and all my tests still passed and my program output was still correct. Perhaps this was corrected in code but the docs weren't updated? --Michael Fawcett
I don't think so... I'm working with version 1.38 and I had a std::map with edge_descriptor keys. I passed this map, wrapped as an associative_property_map, and added to a dynamic_properties object, to graph-reading functions. When I traversed the map contents to do something useful with it, looks like the descriptors where invalid. In some cases it just looked to do nothing. In other cases I got segmentation fault. When I changed to listS, everything worked all right. In the documentation it just says that it's "not guarranted" to work. And looks to be true. Works in some cases and not in others.
On Sun, Mar 15, 2009 at 6:46 PM, Juan Antonio Farré Basurte
wrote: When you say you use vecS for edge storage type, you mean OutEdgeList or EdgeList? I ask that cause in known problems it says that, for the moment, only listS is guarranted to work for EdgeList (the last template parameter of adjacency_list). In fact I tried to use vecS for it and I had serious problems. With listS everything works all right. Of course, for OutEdgeList, vecS is fine :)
I meant for OutEdgeList, however I went back and tried vecS for EdgeList as well and all my tests still passed and my program output was still correct. Perhaps this was corrected in code but the docs weren't updated?
--Michael Fawcett _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
On Mon, Mar 16, 2009 at 5:15 PM, Juan Antonio Farré Basurte
I meant for OutEdgeList, however I went back and tried vecS for EdgeList as well and all my tests still passed and my program output was still correct. Perhaps this was corrected in code but the docs weren't updated?
I don't think so... I'm working with version 1.38 and I had a std::map with edge_descriptor keys. I passed this map, wrapped as an associative_property_map, and added to a dynamic_properties object, to graph-reading functions. When I traversed the map contents to do something useful with it, looks like the descriptors where invalid. In some cases it just looked to do nothing. In other cases I got segmentation fault. When I changed to listS, everything worked all right. In the documentation it just says that it's "not guarranted" to work. And looks to be true. Works in some cases and not in others.
It sounds like something assumes that those descriptors will not be invalidated unless removed. Maybe Andrew can chime in? I would guess it's working for me by accident since I'm never removing anything from the graphs I create. I'll make sure to keep my usage to listS for now. Thanks for the info, --Michael Fawcett
Hi, I was correctly reading graphs in graphml and graphviz. Now I've added support for graph writing. And now I get tons of errors at the last line of my code (I mean symbol '}'). After looking carefully at them looks like there are two families of errors, all of them related to property maps: - Looks like property maps are being accessed for reading using operator[]. But if the property map is backed by std::map, it's documented that operator[] in fact does an insert in the map. This is not a problem when reading a graph, as the graph is mutable. But of course it is a problem when writing a const graph. I get tons of errors about modifying read-only locations and discarding qualifiers (const, of course). - The other errors are about not finding a matching operator>>, also related with properties. In this case, it looks to be related with reading (and I think concretely graphviz), but I don't understand why, as it used to work before. May be this is a cryptic bug of my code. I don't find clear information in the errors about what graph writing function is causing the first family of errors. I can attach compiler output, but I'm afraid messages are in Spanish :S Moreover, I'm not sure if it's correct to send attached files to the list. If anybody wants me to send it, just ask. By the way, I've found a minor problem with graphviz writing. I can't invoke the following template template<typename Graph> void write_graphviz(std::ostream& out, const Graph& g, const dynamic_properties& dp, const std::string& node_id = "node_id"); just this way: write_graphviz(out,g,dp,"name"); Looks like it gets confused with the following template: template < typename VertexListGraph, typename VertexPropertyWriter, typename EdgePropertyWriter
void write_graphviz(std::ostream& out, const VertexListGraph& g, VertexPropertyWriter vpw, EdgePropertyWriter epw); The workaround is easy: write_graphviz(out,g,dp,string("name")); But I find it a bit ugly. Thanks, Juan
2009/3/15 Juan Antonio Farré Basurte
I'm personally using edge descriptors as keys for a map type and it works (I use version 1.38). Vertex descriptors also work with boost::unordered_map, but the sad thing is that edge descriptors don't work with it, and it'd be nice.
Do they work with the attached patch? Daniel
2009/3/15 Juan Antonio Farré Basurte
: I'm personally using edge descriptors as keys for a map type and it works (I use version 1.38). Vertex descriptors also work with boost::unordered_map, but the sad thing is that edge descriptors don't work with it, and it'd be nice.
Do they work with the attached patch?
Daniel _______________________________________________ Boost-users mailing
I'll try it ASAP, Thanks a lot :) list
Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (5)
-
Daniel James
-
James Sutherland
-
Johan Oudinet
-
Juan Antonio Farré Basurte
-
Michael Fawcett