Feasible method of grouping relations

96 Views Asked by At

This might be a bad question, I hope not so bad.

Problem is I have a set of relations(millions), presumably two arrays hold two nodes(starting, and ending), which together forms a relation(edge). I can see the whole picture of these relations is a disjoint graph, which I wish to find the groups of each disjoint part and belonging members.

Any thoughts on how to reduce the order of complexity would be grate appreciated! The question is not so hard, even plain quick finding(matching) would work, and along with other methods. But I am afraid for the millions(roughly 50-100 millions) of records, it cannot possibly be done.

Best!

1

There are 1 best solutions below

0
On

During a day of researching I have found two promising solutions, which are union find and flood fill algo. Union find reference can be fount at https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf; which I think use the improvement version of union find algo, my problem can be solved even in huge data set. Flood fill method I haven't try, but I think in order to use that method I need to have adjacency matrix first, which already takes N*(N-1) operations and memory spaces.