[graph] Bug - add_edge (adjacency_list) does not report if edge already exists as stated in documentation

Hi, I encountered the following problem : a successive call with equal parameters u, v, and g of ============================================================ std::pair<edge_descriptor, bool> add_edge( vertex_descriptor u , vertex_descriptor v , adjacency_list& g ) ============================================================ yields both times "RESULT.second == true". But the documentation states, that only in case it is NOT PRESENT it should be true, which is obviously wrong for the second call. If I use the "edge(u,v,g)" method to check if the edge exists I get the correct result of "edge(u,v,g).second == false" before the first call and "edge(u,v,g).second == true" after the first and before the second call. So the problem is all about the add_edge function and I think it's more a bug than a feature. Because otherwise the bool-flag is obsolete or reports something totally different. Cheers, Martin ============================================================ The boost graph class I use ============================================================ //! The properties available for the nodes of a CoreGraph typedef boost::property< boost::vertex_index_t, size_t , boost::property< boost::vertex_name_t, std::string > > CoreGraph_NodeProperties; //! The properties available for the edges of a CoreGraph typedef boost::property< boost::edge_name_t, std::string > CoreGraph_EdgeProperties; //! The definition of a the internal graph representation typedef boost::adjacency_list< boost::vecS , boost::vecS , boost::undirectedS , CoreGraph_NodeProperties , CoreGraph_EdgeProperties > CoreGraph; ============================================================

Hi Martin, I think everything is more or less correct here. Changing your graph representation to boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS> results in the behavior you expect. Regards, Dmitry Martin Mann wrote:
Hi,
I encountered the following problem :
a successive call with equal parameters u, v, and g of
============================================================ std::pair<edge_descriptor, bool> add_edge( vertex_descriptor u , vertex_descriptor v , adjacency_list& g ) ============================================================
yields both times "RESULT.second == true".
But the documentation states, that only in case it is NOT PRESENT it should be true, which is obviously wrong for the second call.
//! The definition of a the internal graph representation typedef boost::adjacency_list< boost::vecS , boost::vecS , boost::undirectedS , CoreGraph_NodeProperties , CoreGraph_EdgeProperties > CoreGraph;
============================================================

Hi Dmitry, thanks for your reply. Yes this might fix the problem. But than the documentation of "add_edge" is missleading because it should hold for vecS too. Unfortunately I have to stick to vecS due to some other reasons like automatic vertex indexing via properties etc. So I used the workaround with first checking for the presence of the edge via "edge(..).second". Thanks, Martin Dmitry Bufistov wrote:
Hi Martin, I think everything is more or less correct here. Changing your graph representation to boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS> results in the behavior you expect.
Regards, Dmitry
Martin Mann wrote:
Hi,
I encountered the following problem :
a successive call with equal parameters u, v, and g of
============================================================ std::pair<edge_descriptor, bool> add_edge( vertex_descriptor u , vertex_descriptor v , adjacency_list& g ) ============================================================
yields both times "RESULT.second == true".
But the documentation states, that only in case it is NOT PRESENT it should be true, which is obviously wrong for the second call.
//! The definition of a the internal graph representation typedef boost::adjacency_list< boost::vecS , boost::vecS , boost::undirectedS , CoreGraph_NodeProperties , CoreGraph_EdgeProperties > CoreGraph;
============================================================
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Martin Mann wrote:
Hi Dmitry,
thanks for your reply. Yes this might fix the problem. But than the documentation of "add_edge" is missleading because it should hold for vecS too.
Unfortunately I have to stick to vecS due to some other reasons like automatic vertex indexing via properties etc. So I used the workaround with first checking for the presence of the edge via "edge(..).second". Remember, that first template argument of an boost::adjacency_list<> determines OutEdgeList container.
boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>
Dmitry
participants (2)
-
Dmitry Bufistov
-
Martin Mann