change if to match

This commit is contained in:
denon1 2023-04-01 11:52:15 +02:00
parent ec83d01dca
commit 1a73a64b19

View File

@ -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)) {
val productOfMembershipScores = fromNodeWt * memberScores(toNodeId)
ClusterResults(
1,
edgeWt,
0,
0,
samplerMonoid.build(
((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores))))
} else {
ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero) 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) Monoid.sum(resultsIter)(ClusterResultsMonoid)
} }