templates - I'm trying to use this Boost C++ code and I have a problem -


first i'll explain, i'll paste code. copied code example http://www.boost.org/doc/libs/1_45_0/libs/graph/example/prim-example.cpp , i'm trying work input text file, did boost kruskal algorithm.

using debugger, know second argument of function wants "end" array of edges. that's i'm giving function call, don't understand.

graph g(edges, edge_array + num_edges, weights, num_nodes);

i error

1>c:\users\edmond\documents\visual studio 2008\projects\boost prim algo\boost prim algo\main.cpp(61) : error c2661: 'boost::adjacency_list<outedgelists,vertexlists,directeds,vertexproperty,edgeproperty>::adjacency_list' : no overloaded function takes 4 arguments 1>        1>        [ 1>            outedgelists=boost::vecs, 1>            vertexlists=boost::vecs, 1>            directeds=boost::undirecteds, 1>            vertexproperty=boost::property<boost::vertex_distance_t,int>, 1>            edgeproperty=boost::property<boost::edge_weight_t,int> 1>        ] 

here full code. have commented original code, can find original code on website gave.

//======================================================================= // copyright 2001 jeremy g. siek, andrew lumsdaine, lie-quan lee,  // // distributed under boost software license, version 1.0. (see // accompanying file license_1_0.txt or copy @ // http://www.boost.org/license_1_0.txt) //======================================================================= #include <boost/config.hpp> #include <iostream> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/prim_minimum_spanning_tree.hpp>  int main() {   using namespace boost;   typedef adjacency_list < vecs, vecs, undirecteds,     property<vertex_distance_t, int>, property < edge_weight_t, int > > graph;   typedef std::pair < int, int >e;    //const int num_nodes = 5;   //e edges[] = { e(0, 2), e(1, 3), e(1, 4), e(2, 1), e(2, 3),   //  e(3, 4), e(4, 0)   //};   //int weights[] = { 1, 1, 2, 7, 3, 1, 1 };   //int num_edges = 7;  //lire un fichier contenant les 2 structures de données int num_nodes = 0; std::size_t num_edges = 0; int * weights; e * edge_array; static char ligne[50];  //ligne lue bool premierelignefaite = false; file* fichier = fopen("graph_poids.txt", "r"); int = 0;  while (fgets(ligne, 50, fichier) != null) //retourne 0 quand on end-of-file     {         //la premiere ligne est différente         if (premierelignefaite == false) {             //initialiser une matrice d'adjacence nxn             sscanf(ligne, "%d %d", &num_nodes, &num_edges );             edge_array = new e[num_edges];             weights = new int[num_edges];             premierelignefaite = true;             continue;         }         //on construit notre liste d'arêtes         int sommet1, sommet2, poids;         sscanf(ligne, "%d %d %d", &sommet1, &sommet2, &poids);         weights[i] = poids;         edge_array[i].first = sommet1;         edge_array[i].second = sommet2;         i++;     }  e* machin = edge_array + num_edges; //aller au dernier élément    graph g(edges, edge_array + num_edges, weights, num_nodes); //graph g(edges, edges + sizeof(edges) / sizeof(e), weights, num_nodes);   property_map<graph, edge_weight_t>::type weightmap = get(edge_weight, g);    std::vector < graph_traits < graph >::vertex_descriptor >     p(num_vertices(g));    prim_minimum_spanning_tree(g, &p[0]);    (std::size_t = 0; != p.size(); ++i)     if (p[i] != i)       std::cout << "parent[" << << "] = " << p[i] << std::endl;     else       std::cout << "parent[" << << "] = no parent" << std::endl;    return exit_success; } 

here test data if want try it. name of file graph_poids.txt

14 19  0 2 4 0 4 9 0 1 7 1 6 2 2 3 6 3 5 7 3 4 4 4 13 9 5 7 7 5 6 6 6 8 9 6 10 4 7 9 4 7 8 7 8 11 7 8 10 7 9 12 7 9 11 10 12 13 5 

it should "edge_array" , not "edges" (that 1 part of original code).


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -