Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T>
- void caminosAcotados(const Grafo<T, float>& G, const T& u, float maxCoste)
- {
- stringstream ss;
- ss << u;
- caminosAcotados(G, u, maxCoste, ss.str(), 0);
- }
- template <typename T>
- void caminosAcotados(const Grafo<T, float>& G, const T& u, float maxCoste, string camino, int coste)
- {
- Conjunto<Arista<T, float> > conjA = G.aristas();
- cout << "<" << camino << "> Coste: " << coste << endl;
- while(!conjA.esVacio())
- {
- Arista<T, float> a = conjA.quitar();
- if((a.getOrigen() == u) && ((a.getEtiqueta() + coste) <= maxCoste))
- {
- stringstream ss;
- ss << ", " << a.getDestino();
- caminosAcotados(G, a.getDestino(), maxCoste, camino + ss.str(), coste + a.getEtiqueta());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement