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