About
def largestComponent(graph): nodes = [] count = 0 for val in graph: nodes.append(val) visited = set() for node in nodes: if(node is not visited): tempCount = 0
# Perform BFS
queue = []
queue.append(node)
while(len(queue) > 0):
currNode = queue.pop(0)
visited.add(currNode)
for item in graph[currNode] - visited:
queue.append(item)
tempCount = tempCount + 1
if(tempCount >= count):
count = tempCount
return count