Deciding parameter for adjancency list at runtime.

Hi I have a function which take an input from the user whether the graph is directed or undirected. I'm declaring graph as follows :- typedef adjacency_list < vecS, vecS, undirectedS, property < vertex_name_t,std::string >, property < edge_name_t, std::string > > Graph; Graph g; Now here the parameter in Bold need to be varied as the user input changes. One method could be i could have two different function say,CreateDirected() and CreateUndirected(). But this is not working in my case as i want the declaration should be global so that i can use it throughout my application. Please help. Abhishek Vyas Tata Consultancy Services Mailto: abhishek.v@tcs.com Website: http://www.tcs.com ____________________________________________ Experience certainty. IT Services Business Solutions Outsourcing ____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you

I'm new to Boost and the graph library and I don't understand why my compiler complains : error: no matching function for call to `add_edge(int, int, boost::compressed_sparse_row_graph<boost::directedS, void, void, boost::no_property, size_t, size_t>&)' My code is copied underneath : I'm trying to simply create a CSR graph and add an edge ... from the CSR header I see that add_edge is an inline function (same as add_vertex etc...)... Why does this not work ?? Thanks ! Jacques #include <iostream> #include "boost/graph/compressed_sparse_row_graph.hpp" #include "boost/graph/graph_utility.hpp" int main (int argc, char * argv[]){ boost::compressed_sparse_row_graph<> csr; std::cout << "Adding 10 vertices" <<std::endl; boost::num_vertices(csr); boost::add_vertices(10, csr); boost::print_graph(csr); std::cout << "Adding 2 edges" <<std::endl; boost::add_edge(0,1,csr); boost::add_edge(2,1,csr); boost::print_graph(csr); std::cout << "Adding duplicate edge" <<std::endl; boost::add_edge(3,4,csr); boost::add_edge(3,4,csr); boost::print_graph(csr); } --------------------------- This email contains information that is private and confidential and is intended only for the addressee. If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender. Note: All email sent to or from this address may be accessed by someone other than the recipient, for system management and security reasons. Aircraft Research Association Ltd. Registered in England, Registration No 503668 Registered Office: Manton Lane, Bedford MK41 7PF England VAT No GB 196351245

Jacques Papper wrote:
I'm new to Boost and the graph library and I don't understand why my compiler complains :
error: no matching function for call to `add_edge(int, int, boost::compressed_sparse_row_graph<boost::directedS, void, void, boost::no_property, size_t, size_t>&)'
My code is copied underneath : I'm trying to simply create a CSR graph and add an edge ... from the CSR header I see that add_edge is an inline function (same as add_vertex etc...)... Why does this not work ?
It's a template argument deduction failure, because you are passing "int" values where it is expecting "size_t" values... I believe we have fixed this in Boost's Subversion repository, but to work around the problem please use, e.g., add_edge(std::size_t(3), std::size_t(4), csr); - Doug
participants (3)
-
abhishek.v@tcs.com
-
Douglas Gregor
-
Jacques Papper