I remember doing this long back in MySQL using depth-first search but can't remember how I did it. Is there a way to do this directly using a query? I am able to do this in a scripting language but am curious to see the performance using MySQL. Basically, the problem is that I have an adjacency list stored in a table:
A | B
-----
1 | 2
3 | 5
2 | 4
3 | 9
6 | 7
I am trying to find the connected subgraphs of this list to get the following output:
1 2 4
3 5 9
6 7
Any suggestions?