0
I have a graph represented using a dict of sets, e.g.
graph = {
0: {1, 2, 3}, # neighbors of node "0"
1: {0, 2},
2: {0, 1},
3: {0, 4, 5},
4: {3, 5},
5: {3, 4, 7},
6: {8},
7: {5},
8: {9, 6},
9: {8}
}
I use the following code to find connected components ...