Created
April 4, 2013 19:00
-
-
Save prasoon2211/5313156 to your computer and use it in GitHub Desktop.
Sort facebook friend list, closest friend first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An algorithm to sort a person's friend list, closest friends first. | |
Problem: Given the publicly available information on facebook, how to | |
sort the friend list in an order that list closest/most relevant friends | |
first? | |
We are assuming the following things are available (in no particular order): | |
1. Location information: All the locations | |
2. Schools/University attended | |
3. Birthday | |
4. Applications used | |
5. Jobs | |
6. Groups (Common) | |
7. Mutual friends | |
8. Common interests | |
9. Photos (common) | |
10. Statuses - Mendtioned a friend. | |
11. Likes, Comments, Wall Posts | |
12. Netwroks | |
13. Age | |
Let there be person_A whose friend list we have to sort. Let the friends be | |
friend_< i > where 1 < i < 1000. | |
Using the information above, we will solve the problem of finding relevance | |
of friends. | |
Method: | |
------- | |
We loop over all friends, and we calculate a parameter, called relevance, for | |
each friend. To calculate this, we sum over quantities like w*f, where w is | |
the relative weigth for a certain parameter and f is the measure of its quantity. | |
The weigth is calculated dynamically, that is weights depend on the combination | |
of different parameters. We have a weigth calculating function for each | |
parameter. The logic for each function is explained in the algorithm. | |
f is a number that represents the measure of a certain parameter. For example, | |
it might represent the number of mutual friends or the number of common | |
groups. | |
We are taking person_A and friend_< i > to be objects which will be used to | |
access the relevant data. | |
Logic for weigth function: | |
-------------------------- | |
The weigth for any parameter will be calculated using a weight function | |
for each particular parameter. | |
The weight function will be different for each parameter. Also, depending | |
on the parameter, the weights computed will be different. For example, | |
certain parameters, such as number of mutual friends will be given more | |
weight, than say, common interests of persons. The weight functions will | |
take care of this. | |
* We see if both persons are at same location/have been at same locations. | |
Also, same location with presence at same time increases this weight. Also, | |
depends on how many locations the persons have in common. | |
* We assess if both persons have attended same schools/college. This will be given high | |
priority because, given two people went to the same school/college, | |
it is highly likely that they will be closer friends. Accrodingly, we assign a | |
better/worse weight. | |
* We assess if in both are in the same facebook group and also see the | |
number of members in the group. For a group with more members, we'll | |
assign a lower weight and for groups with fewer members, we assign a | |
higher weight. | |
* Determine if the networks are same. | |
* We check if a friend likes my posts, and also check if I like his | |
posts, that is if this goes both ways, then, depending on the mutual | |
interaction, we can assign a weight. | |
* We see the number of pictures in which the person and his friend has been | |
tagged together. | |
* We determine how many times I have mentioned a friend in my status updates and | |
vice - versa. | |
* We analize comment conversations, that is, number of comments made by both | |
persons on the same status update. Also, if say, the person and his friend | |
make successive comments, or if they make many comments in a short period | |
of time, that is a very good indicator of 'closeness'. | |
* We check how many time both persons post on each other's walls. | |
* Common facebook applications used, common interests. It may happen that | |
even though people who do not appear to be good friends may be good friends | |
in real life. | |
Rough Algorithm: | |
---------------- | |
friend_list = [ friend_1, friend_2, ..... , friend_1000 ] | |
relevance_list = [] | |
relevance is a list where we will store the relevance numbers. | |
for friend in friend_list: | |
relevance = 1 | |
w1 = weight_mutual_friends(person_A, friend) | |
Similarly, calculate weights for each of the parameter. | |
Then, claculate relevance as: | |
Summation( w_i*f_i) | |
relevance_list.append(relevance) | |
Now, using this relevance_list, we can sort the friend list. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment