//RelationHrefEntry is (Href, Score, References), RankedNewsItem is (NewsItem, Score)
List<RelationHRefEntry> weightedLinks = new List<RelationHRefEntry>();
foreach (KeyValuePair<RelationHRefEntry, List<RankedNewsItem>> linkNvotes in allLinks) {
Dictionary<string, float> votesPerFeed = new Dictionary<string, float>();
//pick the lower vote if multiple links from a particular feed
foreach (RankedNewsItem voteItem in linkNvotes.Value) {
string feedLink = voteItem.Item.FeedLink;
if(votesPerFeed.ContainsKey(feedLink)){
votesPerFeed[feedLink] = Math.Min(votesPerFeed[feedLink], voteItem.Score);
}else{
votesPerFeed.Add(feedLink, voteItem.Score);
linkNvotes.Key.References.Add(voteItem.Item);
}
}
float totalScore = 0.0f;
foreach (float value in votesPerFeed.Values) {
totalScore += value;
}
linkNvotes.Key.Score = totalScore;
weightedLinks.Add(linkNvotes.Key);
}
weightedLinks.Sort(delegate(RelationHRefEntry x, RelationHRefEntry y) { return y.Score.CompareTo(x.Score);} );
weightedLinks = weightedLinks.GetRange(0, numStories);