# Code wants a num of connected components, using Set() works but Map() seems to fail to check if a node has been visited. Output is 7, expected is 2

The problem is seeing how many connected components there are given an undirected graph. This is the example input. connectedComponentsCount({ 0: [8, 1, 5], 1: [0], 5: [0, 8], 8: [0, 5], 2: [3, 4], 3: [2, 4], 4: [3, 2] }); //Answer should be 2 This is what the graph looks like: 5 —… Read More Code wants a num of connected components, using Set() works but Map() seems to fail to check if a node has been visited. Output is 7, expected is 2