Hi, I am new to Boost Graph Library. I have two questions. I defined my graph like this: struct Node{ int label; int mode[3]; //...;}; struct Edge{ double nCommBord;}; typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, Node, Edge> Graph;Somewhere in my program, I construct it using add_edge() method. What I want is, I allow parallel edges, but I all parallel ones being merged(weight summed together). Can I add edges one by one, and use an general method to 'magically' merge them?(is there a function doing merging?) My second question is, where should I find a complete list of usage of all the library methods(say, manual for add_edge) Thanks, Regards, Shufei _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
On 2/21/07, Shufei Fan
Somewhere in my program, I construct it using add_edge() method. What I want is, I allow parallel edges, but I all parallel ones being merged(weight summed together). Can I add edges one by one, and use an general method to 'magically' merge them?(is there a function doing merging?)
Hi Shufei, No, there's no general method in the BGL to merge edges as you describe. If you want all parallel edges merged, you probably don't want to add parallel edges to begin with. I would suggest defining your graph as typedef boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, Node, Edge> Graph; which disallows parallel edges. add_edge(u,v,g) returns a std::pair consisting of an edge descriptor and a bool signalling whether the edge u,v was added. So check that bool and, if it's false, increment the weight rather than assigning it.
My second question is, where should I find a complete list of usage of all the library methods(say, manual for add_edge)
The online manual is very thorough - in your case, I'd suggest starting here: http://www.boost.org/libs/graph/doc/graph_concepts.html Regards, Aaron
participants (2)
-
Aaron Windsor
-
Shufei Fan