void no_recursive_search_reduce(dgrafo & g, Tour & t, Tour & best_tour, bool pt = 0) {

	tour_pila_t pila;
	pila.push(t);
	while (!pila.empty()){
		Tour actual = pila.top();
		pila.pop();
		if (g.size() == actual.size()) {
			myVector vecinos = g.get_edges(*(actual.firt_city().first));
			int p = g.peso(*(actual.last_city().first), *(actual.firt_city().first));
			city temp(actual.firt_city().first, p);
			actual.insert(temp);
			if (pt){ actual.print();}
			if (best_tour.ranking() > actual.ranking()){
				best_tour = actual;}
			//actual.remove_last_city();
		}else{
			myVector vecinos = g.get_edges(*(actual.last_city().first));
			for (int i=vecinos.size()-1;i>=1;i--){
				if (actual.feasible(*(vecinos[i].first))) {
					actual.insert(vecinos[i]);
					pila.push(actual);
					actual.remove_last_city();
				}
			}
		}
	}
}
void no_recursive_search_parallel(dgrafo & g, Tour & t, Tour & best_tour) {

	tour_pila_t pila;
	pila.push(t);
	omp_lock_t writelock;
	omp_init_lock(&writelock);
	int count = 0;
	#pragma omp parallel
	{
	#pragma omp for 
		for (int u = 0; u<5;u++){

			Tour actual;
			if(!pila.empty()){
				omp_set_lock(&writelock);
				count++;
				omp_unset_lock(&writelock);
				//cout <<"Hola"<<endl;
				actual = pila.top();
				pila.pop();

				if (g.size() == actual.size()) {
					myVector vecinos = g.get_edges(*(actual.firt_city().first));
					int p = g.peso(*(actual.last_city().first), *(actual.firt_city().first));
					city temp(actual.firt_city().first, p);
					actual.insert(temp);
					omp_set_lock(&writelock);
					if (best_tour.ranking() > actual.ranking()){
						best_tour = actual;}
					omp_unset_lock(&writelock);
					//actual.remove_last_city();
				}else{
					myVector vecinos = g.get_edges(*(actual.last_city().first));
					for (int i=vecinos.size()-1;i>=1;i--){
					omp_set_lock(&writelock);
						if (actual.feasible(*(vecinos[i].first))) {
							actual.insert(vecinos[i]);
							pila.push(actual);
							actual.remove_last_city();
						}
					omp_unset_lock(&writelock);
					}
					
				}
			}
		}
		
	}
	cout<<"Contador: "<<count<<endl;
	omp_destroy_lock(&writelock);
}