def req1(catalog,v1,v2): cantidad=model.connectedComponents(catalog) cantidad="El número total de componentes conectados es: "+str(cantidad) v1=model.vertices_buscables(catalog,v1) v2=model.vertices_buscables(catalog,v2) T_f= model.strongly_conected(catalog,v1,v2) if T_f==True: texto= ("Los componentes están en el mismo cluster.") return texto,cantidad elif T_f==0: texto= ("los componentes no están en el mismo cluster.") return texto,cantidad elif T_f== False: texto=("No existe/existen los vertices mencionados") return texto,cantidad
def requerimiento1(analyzer, origin, destination): delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() landingpoints = mp.keySet(analyzer['landingpoints']) capitals = mp.keySet(analyzer['countrypoints']) capital = False vertexa = None vertexb = None for key in lt.iterator(capitals): if origin in key: vertexa = key if destination in key: vertexb = key if vertexa is not None and vertexb is not None: capital = True if not capital: for key in lt.iterator(landingpoints): dataentry = mp.get(analyzer['landingpoints'], key) entry = me.getValue(dataentry) if not vertexa and origin in entry['data']['name']: key = lt.firstElement(entry['points']) vertexa = key if not vertexb and destination in entry['data']['name']: key = lt.firstElement(entry['points']) vertexb = key clusters = model.connectedComponents(analyzer) samecluster = model.sameCluster(analyzer, vertexa, vertexb) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return ((clusters, samecluster), (delta_time, delta_memory))
def connectedComponents(analyzer): """ Numero de componentes fuertemente conectados """ return model.connectedComponents(analyzer)
def connectedComponents(analyzer) -> int: """ Calcula los componentes conectados del grafo Se utiliza el algoritmo de Kosaraju """ return model.connectedComponents(analyzer=analyzer)
def connectedComponents(catalog): """ Numero de componentes conectados """ return model.connectedComponents(catalog)