def requerimiento_4(analyzer,station,resistance): try: resistance=resistance*60 recorrido= bfs.BreadhtFisrtSearch(analyzer['connections'],station) size= gr.numVertices(analyzer['connections']) vertexxx= gr.vertices(analyzer['connections']) dicc= {} for i in range(1,size): ids= lt.getElement(vertexxx,i) vertice= m.get(analyzer['coordinates_destiny'],ids)['value']['name'] if bfs.hasPathTo(recorrido,ids): path= bfs.pathTo(recorrido,ids) sizep= st.size(path) if sizep != 1 : init= st.pop(path) summ= 0 dicc[vertice]= [] while sizep >= 2: vertex2= st.pop(path) if vertex2 is None : break arco= gr.getEdge(analyzer['connections'],init,vertex2) summ+= arco['weight'] init= vertex2 if summ > resistance : dicc[str(vertice)]= None else: dicc[str(vertice)].append(poner_bonita_la_ruta(analyzer,arco)) return dicc except Exception as exp: error.reraise(exp, 'model;Req_4')
def test_infoElements(stack, books): assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, books[5]) st.push(stack, books[6]) st.push(stack, books[3]) st.push(stack, books[10]) st.push(stack, books[1]) st.push(stack, books[2]) st.push(stack, books[8]) st.push(stack, books[4]) st.push(stack, books[7]) st.push(stack, books[9]) elem = st.top(stack) assert (st.size(stack) == 10) assert (elem == books[9]) elem = st.pop(stack) assert (st.size(stack) == 9) assert (elem == books[9]) elem = st.pop(stack) assert (st.size(stack) == 8) assert (elem == books[7]) elem = st.top(stack) assert (st.size(stack) == 8) assert (elem == books[4]) st.push(stack, books[9]) assert (st.size(stack) == 9) elem = st.top(stack) assert (elem == books[9])
def test_error_pop(): """ Este test busca comprobar que es imposible eliminar un objeto de una pila vacia """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) with pytest.raises(Exception): st.pop(stack)
def test_push_pop(): """ Este test prueba que la cola pueda manejar inserciones y eliminaciones de forma correcta siguiendo un orden establecido, y que no quede referencia al objeto sacado despues de haberlo removido de la cola """ stack = st.newStack(list_type) assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, book5) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book6) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book3) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book10) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book1) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book2) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) assert (st.size(stack) == 4) assert book9 == st.pop(stack) assert book7 == st.pop(stack) assert book4 == st.pop(stack) assert book8 == st.pop(stack) assert (st.size(stack) == 0)
def RutasCirculares(analyzer, vertice, limiteInicial, limiteFinal): #REQUERIMIENTO 2 peso = 0 rutas_circulares_total = lt.newList( datastructure='SINGLE_LINKED', cmpfunction=None) #agrupar todas las rutas cicrulares dijkstraIda = djk.Dijkstra(analyzer['connections'], vertice) vertices = gr.vertices(analyzer['connections']) iter2 = it.newIterator(vertices) while it.hasNext(iter2): datos_rutas = lt.newList( datastructure='SINGLE_LINKED', cmpfunction=None) # info todas las rutas cicrulares ruta_circular = lt.newList( datastructure='SINGLE_LINKED', cmpfunction=None ) #lista de nombres de estaciones en la ruta circular vertice2 = it.next(iter2) caminos_ida = djk.pathTo(dijkstraIda, vertice2) #grafo conocer vertices dijkstraVenida = djk.Dijkstra(analyzer['connections'], vertice2) caminos_venida = djk.pathTo(dijkstraVenida, vertice) if not caminos_venida or not caminos_ida: continue while not stack.isEmpty(caminos_ida): dato = stack.pop(caminos_ida) lt.addLast(ruta_circular, dato) while not stack.isEmpty(caminos_venida): dato = stack.pop(caminos_venida) lt.addLast(ruta_circular, dato) # lt.addLast(rutas_circulares_total, ruta_circular) iter = it.newIterator(ruta_circular) while it.hasNext(iter): arco = it.next(iter) duracion = arco['weight'] if (int(limiteInicial) < duracion and duracion < int(limiteFinal)): estacion1 = m.get(analyzer['EstacionesXid'], arco['vertexA']) estacion2 = m.get(analyzer['EstacionesXid'], arco['vertexB']) lt.addLast( datos_rutas, { "estacion1": estacion1, "estacion2": estacion2, "duracion": duracion }) lt.addLast(rutas_circulares_total, datos_rutas) return (rutas_circulares_total)
def dfs_extra(search, graph, vertex, components, path, cycles, weights): """ Funcion auxiliar para calcular un recorrido DFS Args: search: Estructura para almacenar el recorrido vertex: Vertice de inicio del recorrido. Returns: Una estructura para determinar los vertices conectados a source Raises: Exception """ try: if vertex is not None: stk.push(path, vertex) if vertex is not None: cycles[-1].append(vertex) adjlst = g.adjacents(graph, vertex) adjslstiter = it.newIterator(adjlst) while (it.hasNext(adjslstiter)): w = it.next(adjslstiter) if w is not None: visited = map.get(search['visited'], w) vertex_comp = map.get(components, vertex)['value'] w_comp = map.get(components, w)['value'] # if aun no he visitado todos mis hijos if visited is None and vertex_comp == w_comp: map.put(search['visited'], w, { 'marked': True, 'edgeTo': vertex }) edge = g.getEdge(graph, vertex, w)['weight'] current_weight = edge + 20 weights[-1] += current_weight dfs_extra(search, graph, w, components, path, cycles, weights) if g.outdegree(graph, vertex) > 1: new_arr = [] new_arr.append(path['last']['info']) dummy = path['first'] while dummy['next'] is not None: new_arr.append(dummy['info']) dummy = dummy['next'] if new_arr != cycles[-1]: cycles.append(new_arr) weights.append(weights[-1]) map.put(search['visited'], vertex, None) stk.pop(path) except Exception as exp: error.reraise(exp, 'dfs:dfsVertex')
def BuscarRutaMasCorta(analyzer, rangoA, rangoB, origen, destino): A = model.RutaMasRapida(analyzer, rangoA, rangoB, origen, destino) Inicio = stack.pop(A[0])["vertexA"].split("-") Duracion = A[1] print("Ruta de viaje: ") while stack.size(A[0]) > 1: B = stack.pop(A[0])["vertexA"].split("-") print(B[0]) print("------") n = stack.pop(A[0])["vertexB"].split("-") print(n[0]) print("-----------------------------------------") print("Partida del area",Inicio[0],"a la hora",Inicio[1]) print("Duracion en minutos del viaje",str(float(Duracion)/60))
def optionSix(cont, destStation): delta_time = -1.0 tracemalloc.start() start_time = getTime() jose = m.newMap() path = controller.minimumCostPath(cont, destStation) if path is not None: pathlen = stack.size(path) while (not stack.isEmpty(path)): stop = stack.pop(path) if m.contains(jose, stop['vertexB']) == False: m.put(jose, stop['vertexB'], 1) pacho = m.keySet(jose) arias = lt.size(pacho) print('Numero de vertices: ' + str(arias)) print("El numero de arcos es: ", pathlen) else: print('No hay camino') stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time print("Tiempo [ms]: ", f"{delta_time:.3f}")
def req3(catalog, pais_a, pais_b): #sacar capital a partir de país entry1 = mp.get(catalog['map_countries'], pais_a) vert1 = me.getValue(entry1)['CapitalName'] entry2 = mp.get(catalog['map_countries'], pais_b) vert2 = me.getValue(entry2)['CapitalName'] grafo = catalog['graph_landing_points'] lista_ruta = lt.newList() vertices = gr.vertices(catalog['graph_landing_points']) landing_point_a = None landing_point_b = None for vert in lt.iterator(vertices): vertexa = vert.split(sep='*') if vertexa[1] == vert1: landing_point_a = vert elif vertexa[1] == vert2: landing_point_b = vert for vert in lt.iterator(vertices): vertexb = vert.split(sep='*') if vertexb[1] == vert2: landing_point_b = vert elif vertexb[1] == vert1: landing_point_a = vert MST = dijsktra.Dijkstra(grafo, landing_point_a) distancia_total = dijsktra.distTo(MST, landing_point_b) camino_pila = dijsktra.pathTo(MST, landing_point_b) iterador = it.newIterator(camino_pila) while it.hasNext(iterador): ruta = st.pop(camino_pila) lt.addLast(lista_ruta, ruta) return distancia_total, lista_ruta
def RutaMinima(catalog, paisA, paisB): mapaLP = catalog['landing_points'] mapaCountries = catalog['countries'] mapaCountries2 = catalog['countries2'] grafo = catalog['grafo'] capitalA = me.getValue(mp.get(mapaCountries, paisA))['CapitalName'] capitalB = me.getValue(mp.get(mapaCountries, paisB))['CapitalName'] dijkstra = djk.Dijkstra(grafo, capitalA) distancia_total = djk.distTo(dijkstra, capitalB) ruta_cruda = djk.pathTo(dijkstra, capitalB) ruta = qu.newQueue('ARRAY_LIST') previo = None while not stk.isEmpty(ruta_cruda): punto = stk.pop(ruta_cruda)['vertexB'] dist = djk.distTo(dijkstra, punto) if not mp.contains(mapaCountries2, punto): punto = 'Landing point ' + punto.split('-')[0] print(dist) print(punto) p_d = (punto, dist) if not previo == punto: qu.enqueue(ruta, p_d) previo = punto return ruta, distancia_total
def ListaConID(lista): A = [] while stack.size(lista) != 0: B = (stack.pop(lista)) N = B["vertexB"] A.append(N) return A
def PesoDeLaLista(lista): A = 0 while stack.size(lista) != 0: b = (stack.pop(lista)) n = b["weight"] A += float(n) return A
def printReq3(pila): i = 1 tamano = stack.size(pila) while i <= tamano: cable = stack.pop(pila) print('Desde ', cable['vertexA'].split('-')[0], ' hasta ', cable['vertexB'].split('-')[0], ' con una distancia de ', cable['weight']) i+=1
def test_dfo(graph): search = dfo.DepthFirstOrder(graph) assert stack.size(search['reversepost']) == 10 print('') while not stack.isEmpty(search['reversepost']): top = stack.pop(search['reversepost']) print(top)
def recorrido_resistencia(analyzer, initStation, Tmax): newGraph = bfs.BreadhtFisrtSearch(analyzer["graph"], initStation, Tmax) #archivo=open("perro.txt","w") #archivo.write(str(newGraph)) #print(newGraph["visited"]["table"]) keys = m.keySet(newGraph["visited"]) iterator = it.newIterator(keys) rutas = [] while it.hasNext(iterator): station = it.next(iterator) #for el in newGraph["visited"]["table"]["elements"]: #if el["key"]!=None and el["value"]["final"]==True: if me.getValue(m.get(newGraph["visited"], station))["final"] == True: ruta = [] path = bfs.pathTo(newGraph, station) i = 0 while not st.isEmpty(path): entry = st.pop(path) if entry == initStation: ruta = {"Estaciones": [entry], "Duraciones": []} else: ruta["Estaciones"].append(entry) edge = gr.getEdge(analyzer["graph"], ruta["Estaciones"][i - 1], entry) duration = edge['weight'] / 60 ruta["Duraciones"].append(duration) i += 1 rutas.append(ruta) return rutas
def printOptionSeven(route): """ RETO4 | REQ5 Imprime el requerimiento 5. """ if route is not None: departure_station, arrival_station, pathTo, age_range, cost = route print('\nLa edad ingresada se encuentra en el rango de: ' + str(age_range) + ' años.') print('Estación inicial más común para la edad ingresada: ' + str(departure_station['key']) + ' con: ' + str(departure_station['value']['Departure_Ages'][age_range]) + ' viajes.') print('Estación final más común para la edad ingresada: ' + str(arrival_station['key']) + ' con: ' + str(arrival_station['value']['Arrival_Ages'][age_range]) + ' viajes.') if pathTo is None: print('No hay ruta válida que conecte a las dos estaciones.') else: print( 'La ruta más corta entre estas dos estaciones, tiene un costo de: ' + str(cost) + ' segundos, el recorrido es: ') while (not stack.isEmpty(pathTo)): station = stack.pop(pathTo) print( str(station['vertexA']) + ' - ' + str(station['vertexB'])) else: print('La edad ingresada no es válida.')
def routeByResistance(citibike, initialStation, resistanceTime): try: dijsktra = djk.Dijkstra(citibike["connections"], initialStation) vertices = gr.vertices(citibike["connections"]) iterator = it.newIterator(vertices) trueStations = st.newStack() stops = m.newMap(numelements=768, maptype="CHAINING", loadfactor=1, comparefunction=compareStopIds) while it.hasNext(iterator): element = it.next(iterator) if element != initialStation and djk.hasPathTo(dijsktra, element) is True: if m.get(stops, element) is None or getElement(m.get(stops, element))["value"] is False: if djk.distTo(dijsktra,element) <= resistanceTime: pila= djk.pathTo(dijsktra,element) pila2 = djk.pathTo(dijsktra,element) size_pila = 0 repetition = False lon_pila = st.size(pila) watcher = {"value": True} while size_pila < lon_pila and repetition == False: pop = st.pop(pila)["vertexB"] if m.get(stops,pop) is None or getElement(m.get(stops,pop))["value"] is False: m.put(stops,pop,watcher) else: repetition = True watcher["value"]=False size_pila +=1 if repetition == False: st.push(trueStations, pila2) return trueStations except: return None
def getBestSchedule(graph, pickUp, dropOff, InitialTime, EndTime): bestSchedule = InitialTime currentStamp = InitialTime first = getTime(graph, pickUp, dropOff, currentStamp) bestTime = first[0] search = first[1] while currentStamp != EndTime: currentStamp = add15(currentStamp) time = getTime(graph, pickUp, dropOff, currentStamp) if time[0] < bestTime: bestSchedule = currentStamp bestTime = time[0] search = time[1] path = [] pathTo = djk.pathTo(search, dropOff) if pathTo is None: path = None else: while not st.isEmpty(pathTo): edge = st.pop(pathTo) Com = edge["vertexA"] path.append(Com) if st.size(pathTo) == 0: Com2 = edge["vertexB"] path.append(Com2) return bestSchedule, path, bestTime
def test_top_pop(): """ Este test prueba la creacion de una cola y que el orden de salida sea el correcto para la estructura en cuestion, y que el tamaño se reduzca para cada salida de objeto """ stack = st.newStack(list_type) assert st.size(stack) == 0 assert st.isEmpty(stack) st.push(stack, book5) st.push(stack, book6) st.push(stack, book3) st.push(stack, book10) st.push(stack, book1) st.push(stack, book2) st.push(stack, book8) st.push(stack, book4) st.push(stack, book7) st.push(stack, book9) total = st.size(stack) while not (st.isEmpty(stack)): top = st.top(stack) assert (st.pop(stack) == top) total -= 1 assert (total == st.size(stack))
def optionFour(): verticeCentral = input( "Ingrese la estación para la cual desea realizar la consulta (Ejemplo 3661, 477): " ) LimiteInferior = (int( input("Ingrese el limite inferior del rango a consultar (Ej 120): ")) ) * 60 LimiteSuperior = (int( input("Ingrese el limite superior del rango a consultar (Ej 240): ")) ) * 60 listaAdyacentes = controller.ListaAdyacentes(cont, verticeCentral, LimiteInferior, LimiteSuperior) print("\nSe encontraron en total {} rutas cíclicas:\n ".format( listaAdyacentes[0])) while (not stack.isEmpty(listaAdyacentes[1])): stop = stack.pop(listaAdyacentes[1]) print( "Esta ruta tarda en total {} minutos, tiene {} estaciones, teniendo en cuenta un tiempo de 20 minutos por estacion. " .format( (round((stop["PesoPorRuta"] / 60), 2)), str(queue.size(stop)), )) while stop and (not queue.isEmpty(stop)): stopDOS = queue.dequeue(stop) print( "-> Parte de la estacion {}, hasta la estación {} y tarda {} minutos en el trayecto. " .format(stopDOS['vertexA'], stopDOS['vertexB'], round((stopDOS['weight'] / 60), 2))) print("\n")
def print_req3(catalog, pais1, pais2): path = controller.req3(catalog, pais1, pais2) recorrido = 0 print_separador_gigante() print("Ruta:") print_separador_sensillo() if path is not None: if "No se ha encontrado los/el pais que está buscando " not in path: while (not stack.isEmpty(path)): point = stack.pop(path) recorrido += int(point["weight"]) print("Landig Point A: " + str(controller.des_vertice(point["vertexA"])) + ", " + " Landig Point B: " + str(controller.des_vertice(point["vertexB"])) + ", " + " Distancia: " + str(point["weight"]) + " km") print_separador_sensillo() print("El recorrido total es de: " + str(recorrido) + " km") print_separador_gigante() else: print(path) print_separador_gigante else: print_separador_sensillo() print("No se ha encontrado un camino") print_separador_gigante()
def findShortestPath(analyzer, pais1, pais2): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() answer = model.findShortestPath(analyzer, pais1, pais2) path = [] while st.size(answer[0]) > 0: step = st.pop(answer[0]) path.append({ 'origin': step['vertexA'], 'destination': step['vertexB'], 'distance': step['weight'] }) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return analyzer, path, answer[1], delta_time, delta_memory
def optionFour(catalog, country_1, country_2): "Req 3 - Dijkstra" capital_1 = controller.getCapitalCity(catalog, country_1) capital_2 = controller.getCapitalCity(catalog, country_2) if (capital_1 is not None) and (capital_2 is not None): path = controller.minimumDistanceCountries(catalog, capital_1, capital_2) if path is not None: path_folium = path.copy() printMapDijkstra(catalog, path_folium) print("\nPresione 'enter' para ver el siguente\n") total_dist = 0.0 while not stack.isEmpty(path): edge = stack.pop(path) total_dist += edge['weight'] print(edge['vertexA'] + "-->" + edge['vertexB'] + " costo: " + str(edge['weight']) + " km") input() print('El costo total es de ', total_dist, 'km') else: print('No existe el camino entre', capital_1, 'y', capital_2) else: print('Alguno de los paises no fue valido')
def optionSix(): path = controller.routeByResistance(cont, initialStation, resistanceTime) if path is None: print("La ruta que introdujiste no existe.") else: if stack.isEmpty(path) is False: for i in range(0, stack.size(path)): print("\nRuta", i + 1) sub_pila = stack.pop(path) for j in range(0, stack.size(sub_pila)): edge = stack.pop(sub_pila) print("Segmento", j + 1) print("Entre", edge["vertexA"], "y", edge["vertexB"], "te demoras", float(edge["weight"]) / 60, "minutos") else: print("No hay ninguna ruta para ese tiempo estipulado")
def hayarEstaciones(cont, initialStation): informacion = gr.adjacents(cont["connections"], initialStation) lista=[] if stack.isEmpty(informacion) == False: for i in range(0, stack.size(informacion)): sub_pila = stack.pop(informacion) lista.append(sub_pila) return lista
def test_push_pop(stack, books): assert (st.size(stack) == 0) assert (st.isEmpty(stack)) st.push(stack, books[5]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[6]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[3]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[10]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[1]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[2]) assert (st.size(stack) == 1) assert (st.top(stack) == st.pop(stack)) assert (st.size(stack) == 0) st.push(stack, books[8]) st.push(stack, books[4]) st.push(stack, books[7]) st.push(stack, books[9]) assert (st.size(stack) == 4) assert books[9] == st.pop(stack) assert books[7] == st.pop(stack) assert books[4] == st.pop(stack) assert books[8] == st.pop(stack) assert (st.size(stack) == 0)
def Ruta_interes_turistico(grafo, latitud1, longitud1, latitud2, longitud2): Latitud1 = float(latitud1) / 57.29577951 Longitud1 = float(longitud1) / 57.29577951 Latitud2 = float(latitud2) / 57.29577951 Longitud2 = float(longitud2) / 57.29577951 menor = None menor_dist = 10000000000 menor2 = None menor_dist2 = 10000000000 estaciones = grafo["Estaciones"] entry = m.keySet(estaciones) iterador = it.newIterator(entry) while it.hasNext(iterador): elemento = it.next(iterador) entry = m.get(estaciones, elemento) valor = me.getValue(entry) latitud = float(valor["Latitud"]) / 57.29577951 longitud = float(valor["Longitud"]) / 57.29577951 dis_estacion_salida = 3963.0 * math.acos( math.sin(Latitud1) * math.sin(latitud) + math.cos(Latitud1) * math.cos(latitud) * math.cos(longitud - Longitud1)) dis_estacion_llegada = 3963.0 * math.acos( math.sin(Latitud2) * math.sin(latitud) + math.cos(Latitud2) * math.cos(latitud) * math.cos(longitud - Longitud2)) if dis_estacion_salida <= menor_dist: menor = elemento menor_dist = dis_estacion_salida if dis_estacion_llegada <= menor_dist2: menor2 = elemento menor_dist2 = dis_estacion_llegada lista = lt.newList("ARRAY_LIST", comparar_esta) path = djk.Dijkstra(grafo["graph"], menor) path_ = djk.pathTo(path, menor2) costo = djk.distTo(path, menor2) estaciones = grafo["Estaciones"] entry_sal = m.get(estaciones, menor) entry_lle = m.get(estaciones, menor2) estacion_sali = me.getValue(entry_sal)["Nombre"] estacion_lleg = me.getValue(entry_lle)["Nombre"] while (not st.isEmpty(path_)): stop = st.pop(path_) entryA = m.get(estaciones, stop["vertexA"]) estacion_1 = me.getValue(entryA)["Nombre"] if lt.isPresent(lista, estacion_1) == 0: lt.addLast(lista, estacion_1) entryB = m.get(estaciones, stop["vertexB"]) estacion_2 = me.getValue(entryB)["Nombre"] if lt.isPresent(lista, estacion_2) == 0: lt.addLast(lista, estacion_2) return lista, estacion_sali, estacion_lleg, costo
def test_cycle(cgraph): search = c.DirectedCycle(cgraph) assert c.hasCycle(search) is True path = c.cycle(search) print('\n') while not stack.isEmpty(path): edge = stack.pop(path) print(edge['vertexA'] + "-->" + edge['vertexB'] + " costo: " + str(edge['weight']))
def optionSix(): path = controller.minimumCostPath(cont, destStation) if path is not None: pathlen = stack.size(path) print('El camino es de longitud: ' + str(pathlen)) while (not stack.isEmpty(path)): stop = stack.pop(path) print(stop) else: print('No hay camino')
def test_dijkstra_armenia(graph): search = djk.Dijkstra(graph, 'Bogota') assert djk.hasPathTo(search, 'Armenia') is True path = djk.pathTo(search, 'Armenia') print('\n') while not stack.isEmpty(path): edge = stack.pop(path) print(edge['vertexA'] + "-->" + edge['vertexB'] + " costo: " + str(edge['weight'])) print(str(djk.distTo(search, 'Armenia')))