mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-22 18:21:51 +01:00
Compare commits
2 Commits
9bf64a29ce
...
e839fe55ec
Author | SHA1 | Date | |
---|---|---|---|
|
e839fe55ec | ||
|
1a73a64b19 |
@ -90,21 +90,14 @@ object ClusterEvaluation {
|
||||
val resultsIter = membersAdjLists.flatMap {
|
||||
case (fromNodeId, adjList) =>
|
||||
val fromNodeWt = memberScores.getOrElse(fromNodeId, 0.0)
|
||||
adjList.map {
|
||||
case (toNodeId, edgeWt) =>
|
||||
if (memberScores.contains(toNodeId)) {
|
||||
val productOfMembershipScores = fromNodeWt * memberScores(toNodeId)
|
||||
ClusterResults(
|
||||
1,
|
||||
edgeWt,
|
||||
0,
|
||||
0,
|
||||
samplerMonoid.build(
|
||||
((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores))))
|
||||
} else {
|
||||
adjList.map(ad => ad match {
|
||||
case (toNodeId,edgeWt) if (!memberScores.contains(toNodeId)) =>
|
||||
ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero)
|
||||
}
|
||||
}
|
||||
case (toNodeId,edgeWt) =>
|
||||
val productOfMembershipScores = fromNodeWt * memberScores(toNodeId)
|
||||
val sampler = samplerMonoid.build((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores))
|
||||
ClusterResults(1, edgeWt, 0, 0, sampler)
|
||||
})
|
||||
}
|
||||
Monoid.sum(resultsIter)(ClusterResultsMonoid)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user