if len(vertices_encountered) != len(vertices): for vertex in gdi from graph2 import Graph g = {"a": ["d"], "b": ["c"], "c": ["b", "c", "d", "e"], "d": ["a", "c"], "e": ["c"], "f": [] } graph = Graph(g) print(graph) for node in graph.vertices(): print(graph.vertex_degree(node)) print("List of isolated vertices:") print(graph.find_isolated_vertices()) print("""A path from "a" to "e":""") print(graph.find_path("a", "e")) print("""All pathes from "a" to "e":""") print(graph.find_all_paths("a", "e")) print("The maximum degree of the graph is:") print(graph.Delta()) print("The minimum degree of the graph is:")
19 : [18, 20, 11], 20 : [13, 16, 19] } """ g = { 1: [2, 3, 4], 2: [1, 5], 3: [1, 4, 5], 4: [1, 3, 6], 5: [2, 3, 6], 6: [4, 5] } graph = Graph(g) vertices = graph.vertices() grados = [] numVertices = 0 nodosAdyacentes = [] nodosRecorridos = [] gradoAdyacentes = [] hamiltoniano = True nodoActual = None #creamos la lista de grados vacía pero #con tantos elementos como vértices #Cada entrada contendrá el grado del nodo i, siendo i la posición #relativa en la lista for item in vertices: grados.append([])