社交网络排名算法

时间:2012-05-05 13:49:25

标签: c# linq algorithm ranking

我正在尝试根据喜欢,评论和转发接收次数和时间为社交网络开发一个简单的排名算法。我一直在阅读Facebook使用的边缘排名算法,并尝试做类似的事情,但我无法做到正确。

该算法现在应该显示热门帖子。

这是我试过的:

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

有没有人有更好的解决方案?

1 个答案:

答案 0 :(得分:3)

您可以使用PageRank algorithm为每个人提供受欢迎程度。此算法用于使用它们之间的链接对网站进行排名,但您可以使用注释,转发和喜欢(使用不同的系数)而不是链接。

如果您认为PageRank难以实现(因为数据的大小),您可以使用opic algorithm来产生相同的结果,但需要的内存要少得多。