Social media provides us with recommendations and suggestions for new friends. Most such platforms use the Friends-Of-Friends (fof) algorithm.
Friends-Of-Friends (fof) is implemented using the shortest-path algorithm.
It helps social media platforms to broaden their network of users.
The friends-of-friends algorithm suggests friends that users may know but who aren’t part of their immediate network.
Two Map-Reduce jobs are required to calculate the FoFs for each user in a social network. The first one calculates the common friends for each user and the second job sorts the common friends by number of connections to your friends.
Now you can suggest friends from a sorted list.
Our goal is to determine all fofs and order them by number of friends in common.
In this case expected results have jyo as the first FoF recommendation followed by vir then kai.
The text file that represents social graph is:
tar vir sac kai jyo
pra sac vir jyo tar
sac kai jyo pra
vir sac kai jyo
Jyo pra kai sac vir tar
for all adjnode in node.adjacencyList do
for all adj2node in node.adjacencyList do
If the tuple(adjnodeName,adj2nodeName) hasn’t already been
for all i in counts[i1,i2….] do
If i=1 then
If alreadyFriends not true then
Output of first job is against graph is
Sac jyo 3
Pra tar 1
Pra sac 2
Pra kai 2
Partition by nodeName
sort by tuple(nodeName,commonFriends)
For all t in [tuple1,tuple2….]
Output of second MapReduce job will be like
Sac jyo : 3
Pra jyo : 2 vir : 2 tar : 1