Facebook has the ability to order users (e.g. in the search) according to the mutual friend count. Another example is the friend finder. The order is more or less the same thing.
My Question is: How can they keep track of the mutual friend counts, since you have friends of friends? How can they order friends in such a short time?
If we just assume that every user has 100 friends, simply that would in a worst case mean that for every person there must be n^2 = 10'000 entries per user in such an index.
There must be some indexing technique, but I really wonder how they do that on the database level.