Boost logo

Boost Users :

From: Gustavo S˙ffffe1nchez (gustsanc_at_[hidden])
Date: 2004-11-22 11:30:42


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 <class Graph, class Tag>
struct buscaVia
 : public boost::base_visitor<buscaVia<Graph, Tag> >
{
 typedef Tag event_filter;
 buscaVia(typename property_map<Graph, vertex_info_t>::type & vinfo_,
   property_map<UGraph, edge_component_t>::type & ecomp,Vertex & _via,vector<Vertex> &p)
  :vinfo(vinfo_),encontrada(false),_ecomp(ecomp),via(_via),_p(p){}
 template <class Vertex, class Graph>
  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<Graph, vertex_info_t>::type & vinfo;
 property_map<UGraph, edge_component_t>::type & _ecomp;
 bool encontrada;
 Vertex & via;
 vector<Vertex> &_p;
};
template<class Graph, class Tag>
inline buscaVia<Graph,Tag>
_buscaVia(Graph &g, Tag,typename property_map<Graph, vertex_info_t>::type & vinfo,
    property_map<UGraph, edge_component_t>::type & ecomp,
    Vertex & _via, vector<Vertex> &p){
 return buscaVia<Graph,Tag>(vinfo,ecomp,_via,p);
}

///////end of codes for visitor

We appreciate your kind help!
 Yang

                
---------------------------------



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net