How can I prove the “Six Degrees of Separation” concept programmatically?

前端 未结 4 1093
-上瘾入骨i
-上瘾入骨i 2021-01-31 23:22

I have a database of 20 million users and connections between those people. How can I prove the concept of \"Six degrees of separation\" concept in the most efficient w

4条回答
  •  心在旅途
    2021-01-31 23:43

    I think the most efficient way (worst case) is almost N^3. Build an adjacency matrix, and then take that matrix ^2, ^3, ^4, ^5 and ^6. Look for any entries in the graph that are 0 for matrix through matrix^6.

    Heuristically you can try to single out subgraphs ( large clumps of people who are only connected to other clumps by a relatively small number of "bridge" nodes ) but there's absolutely no guarantee you'll have any.

提交回复
热议问题