I want to find my friend whom I share with them the highest number of mutual friends.
I tried to do it with FQL and graph API the following way:
Get the friends list of the current logged in user.
FQL: SELECT uid1 FROM friend WHERE uid2="MY_USER_ID" and uid1 IN (SELECT uid1 FROM friend WHERE uid2=me())
Graph API: $facebook->api('/me/friends?format=json&limit=5000')
For each one of the uid's in the list, I can get the list of mutual friends and count it.
FQL: SELECT uid1 FROM friend WHERE uid2="OTHER_USER" and uid1 IN (SELECT uid1 FROM friend WHERE uid2=me())
Graph API: $facebook->api('me/mutualfriends/OTHER_USER')
HOWEVER, it takes TONS of time to run this through all my friends...
Are you familiar with a better way to do that?
If your goal is only to get a list of friends with highest number of mutual friends, i.e., you do not care who those mutual friends are, then actually Geoff's FQL call provided way too much information then you need.
I also notice that Geoff's FQL returns so much data and Facebook actually truncates the data.
Besides, you might want to get the names of those friends in the same FQl call...
An alternative FQL that looks better is this:
SELECT name,mutual_friend_count FROM user WHERE uid IN(
SELECT uid2 FROM friend WHERE uid1=me())
This returns you the number of mutual friends from your friend list. So if you have 500 friends, you will only get a response with 500 objects.