Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/src/test/scala/org/graphframes/ldbc/TestLDBCCases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ class TestLDBCCases extends SparkFunSuite with GraphFrameTestSparkContext {

Seq("graphx", "graphframes").foreach { algo =>
test(s"test undirected CDLP with LDBC for algo ${algo}") {
// I have no idea how to write it so it will work
if (scala.util.Properties.versionNumberString.startsWith("2.12") && algo == "graphx") {
cancel("CDLP implementations are broken in 2.12, see #571")
}
val testCase = ldbcTestCDLPUndirected
val cdlpResults = testCase._1.labelPropagation.setAlgorithm(algo).maxIter(testCase._3).run()
assert(cdlpResults.count() == testCase._1.vertices.count())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package org.apache.spark.graphframes.graphx.lib
import org.apache.spark.graphframes.graphx._

import scala.annotation.nowarn
import scala.collection.Map
import scala.collection.mutable
import scala.reflect.ClassTag

/** Label Propagation algorithm. */
Expand Down Expand Up @@ -53,26 +51,17 @@ object LabelPropagation {
require(maxSteps > 0, s"Maximum of steps must be greater than 0, but got ${maxSteps}")

val lpaGraph = graph.mapVertices { case (vid, _) => vid }
def sendMessage(e: EdgeTriplet[VertexId, ED]): Iterator[(VertexId, Map[VertexId, Long])] = {
Iterator((e.srcId, Map(e.dstAttr -> 1L)), (e.dstId, Map(e.srcAttr -> 1L)))
}
def mergeMessage(
count1: Map[VertexId, Long],
count2: Map[VertexId, Long]): Map[VertexId, Long] = {
// Mimics the optimization of breakOut, not present in Scala 2.13, while working in 2.12
val map = mutable.Map[VertexId, Long]()
(count1.keySet ++ count2.keySet).foreach { i =>
val count1Val = count1.getOrElse(i, 0L)
val count2Val = count2.getOrElse(i, 0L)
map.put(i, count1Val + count2Val)
}
map
def sendMessage(e: EdgeTriplet[VertexId, ED]): Iterator[(VertexId, Vector[Long])] = {
Iterator((e.srcId, Vector(e.dstAttr)), (e.dstId, Vector(e.srcAttr)))
}
def mergeMessage(left: Vector[Long], right: Vector[Long]): Vector[Long] = left ++ right

@nowarn
def vertexProgram(vid: VertexId, attr: Long, message: Map[VertexId, Long]): VertexId = {
if (message.isEmpty) attr else message.maxBy(_._2)._1
def vertexProgram(vid: VertexId, attr: Long, message: Vector[Long]): Long = {
if (message.isEmpty) attr
else message.groupBy(f => f).map(f => (f._1, f._2.size)).maxBy(f => (f._2, -f._1))._1
}
val initialMessage = Map[VertexId, Long]()
val initialMessage = Vector[Long]()
Pregel(lpaGraph, initialMessage, maxIterations = maxSteps)(
vprog = vertexProgram,
sendMsg = sendMessage,
Expand Down