Hello, all
We are doing a algorithm based on the graph boost library. Actually, it will be a Dinamic Link Library(dll). Our problem is when we execute it in console mode, it costs 12 seconds to finish, while it costs 120 seconds more or less when we are calling it as a DLL from Visual Basic.
We have traced into the source code and found that is the dijkstra_shortest_paths function from the boost library which costs us 10 times more in the dll than the console mode.
We call the dijkstra_shortest_paths like this:
dijkstra_shortest_paths(g,s,predecessor_map(&p[0]).distance_map(&d[0]).
visitor(make_dijkstra_visitor(_buscaVia(g,on_finish_vertex(),vinfo,edge_comp,via,p) )));
///////below is the codes for visitor
template
struct buscaVia
: public boost::base_visitor >
{
typedef Tag event_filter;
buscaVia(typename property_map::type & vinfo_,
property_map::type & ecomp,Vertex & _via,vector<Vertex> &p)
:vinfo(vinfo_),encontrada(false),_ecomp(ecomp),via(_via),_p(p){}
template
void operator() (Vertex v, Graph& g){
bool hay_comp=false;
Vertex a=v;
if( vinfo[v].is_via && ! encontrada ){
while(_p[a]!=a){// mientras no hayamos llegado al origen
if( _ecomp[edge(a,_p[a],g).first]->isComponentCaerTension() ){hay_comp=true; break;}
else a=_p[a]; //pasamos al anterior
}
if(hay_comp==false){ // encontramos la via de la bobina
DEBUG_CODE(cout << " via encontrada: " << vinfo[v].vertex_name << endl;)
via = v;
encontrada=true;
}
}
DEBUG_CODE(else cout << "pasamos por vertice: " << vinfo[v].vertex_name << endl;)
}
private:
typename property_map::type & vinfo;
property_map::type & _ecomp;
bool encontrada;
Vertex & via;
vector<Vertex> &_p;
};
template
inline buscaVia
_buscaVia(Graph &g, Tag,typename property_map::type & vinfo,
property_map::type & ecomp,
Vertex & _via, vector<Vertex> &p){
return buscaVia(vinfo,ecomp,_via,p);
}
///////end of codes for visitor
We appreciate your kind help!
Yang
---------------------------------