开发者

Connected Subgraphs in MySQL using adjacency list?

开发者 https://www.devze.com 2023-01-18 18:12 出处:网络
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 a

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 adj开发者_如何学编程acency 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消