Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Social Network Ranking Algorithm

I am trying to develop a simple ranking algorithm for a social network based on the number of likes, comments, and reposts receiving and time. I have been reading about the edge rank algorithm that facebook uses and tried to do something similar but I cannot get it right.

The algorithm should show the popular posts now.

Here is what i tried:

let nComments = (from c in db.Comments where c.postid == r.pageOwner.PostId select c).Count()

let nReposts = (from s in db.Posts where s.RepostedFrom_postid == r.pageOwner.PostId select s).Count()

let nLikes = (from u in db.UserPageRelations where u.Post_id == r.pageOwner.PostId select u).Sum(s => s.Rate)

let TimeDecayFactor = ignoretime ? 1 : Math.Exp(-(DateTime.Now - Post.Date).TotalHours)

let TotalEdge = (1 * nComments + 3 * nLikes + 2 * nReposts + 1) * TimeDecayFactor

 orderby (TotalEdge) descending

does anyone have a better solution?

like image 529
Marwan Roushdy Avatar asked Sep 16 '25 11:09

Marwan Roushdy


1 Answers

You could use the PageRank algorithm to give a popularity to everyone. This algorithm is designed for ranking websites using links between them but you can use comments, reposts and likes (with different coefficients) instead of links.

If you think PageRank is too tough to implement (because of the size of the data), you can use the opic algorithm which produces the same results but requires significantly less memory.

like image 182
Thomash Avatar answered Sep 19 '25 00:09

Thomash