Social Network Ranking Algorithm

algorithm, c#, linq, ranking

Solution

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.

Problem

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?

Original source