-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBusquedasCiegas.cpp
37 lines (35 loc) · 964 Bytes
/
BusquedasCiegas.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "algoritmos.hpp"
//----------SOBRECARGAMOS << PARA IMPRIMIR GRAFOS----------------
ostream& operator<<(ostream &out,const Grafo &grafo){
for(auto const &vertice : grafo){
out<<vertice.first<<": ";
out<<"[";
for(size_t i=0;i<vertice.second.size();i++){
out<<vertice.second[i];
if(i!=vertice.second.size()-1){
out<<",";
}
}
out<<"]";
out<<endl;
}
return out;
}
int main(){
Grafo grafo;
//-------DISEÑAMOS LA ESTRUCTURA DEL GRAFO---------------------------
grafo["A"]={"B","C","D"};
grafo["B"]={"A","H"};//vertice b conectado a la A y H
grafo["C"]={"A","G","F"};
grafo["D"]={"A","E"};
grafo["E"]={"D","K"};
grafo["F"]={"C","J"};
grafo["G"]={"C","J"};
grafo["H"]={"B","I"};
grafo["I"]={"H","J"};
grafo["J"]={"F","G","I","K"};
grafo["K"]={"E","J"};
vector<string> recorrido=busqueda_profundidad(grafo);
for(auto const &vertice:recorrido)
cout<<vertice<<endl;
}