Lab Week 9 Breadth-First Search Imported Code Project Code from random import randint import sys import string class graphNode: def __init__(self, value): self.value = value self.edges = [] self.depth = -1 self.path = ' 0' self.visited = False def BFS(self): if self.visited: return False self.visited = True for v in self.edges: if v.depth > self.depth + 1 or v.depth < 0: v.depth = self.depth + 1 v.path = self.path + ' -> {:>4d}'.format(v.value) print('{:>4d}, {}'.format(self.depth, self.path)) return True Commands VertexNumber = 1000 VertexList = [] for i in range(VertexNumber): VertexList.append(graphNode(i)) for v in VertexList: e = randint(5, 10) e -= len(v.edges) while e > 0: n = randint(0, VertexNumber - 1) if len(VertexList[n].edges) < 10: VertexList[n].edges.append(v) v.edges.append(VertexList[n]) e -= 1 VertexList[0].depth = 0 VertexQueue = [VertexList[0]] count = 0 for v in VertexList: count += len(v.edges) print('Number of edges is: ' + (count / 2).__str__()) while len(VertexQueue): v = VertexQueue.pop(0) enqueue = v.BFS() if enqueue: VertexQueue += v.edges Run Output