I believe it is pre-computed and not done when you load the page. How? There are a couple of options to look at this problem. A common way is to look at the data as a graph, where each person is a vertex, and an edge defines a friendship. Iterating through each existing pair of persons, and finding 2 edges paths. The vertexes you went over, are the mutual friends. If you really want to get into it, I would suggest starting with learning about Graph Theory
When dealing with such an amount of data, using MySql and queries won't work. On small amounts of data, it will.
发布评论
评论(1)
我相信它是预先计算的,并且在加载页面时并未完成。
如何?有几个选项可以解决这个问题。
一种常见的方法是将数据视为图表,其中每个人都是一个顶点,一条边定义了友谊。迭代每对现有的人,并找到 2 条边缘路径。你走过的顶点,是共同的朋友。如果你真的想深入了解它,我建议你从学习图论开始
。这么大的数据量,使用MySql和查询是不行的。对于少量数据,它会的。
I believe it is pre-computed and not done when you load the page.
How? There are a couple of options to look at this problem.
A common way is to look at the data as a graph, where each person is a vertex, and an edge defines a friendship. Iterating through each existing pair of persons, and finding 2 edges paths. The vertexes you went over, are the mutual friends. If you really want to get into it, I would suggest starting with learning about Graph Theory
When dealing with such an amount of data, using MySql and queries won't work. On small amounts of data, it will.