This is an automated email from the ASF dual-hosted git repository.

zhengruifeng pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 14ff36020a72 [SPARK-42856][GRAPHX] Break tie with highest vertex id in 
label propagation
14ff36020a72 is described below

commit 14ff36020a728ae8be382019c54bc6801a949fdb
Author: awadhesh singh <[email protected]>
AuthorDate: Mon Nov 2 18:19:09 2026 +0800

    [SPARK-42856][GRAPHX] Break tie with highest vertex id in label propagation
    
    ### What changes were proposed in this pull request?
    Update the tie breaking logic in label propagation to consider the max 
vertex id.
    
    ### Why are the changes needed?
    This is a bug reported in 
[SPARK-42856](https://issues.apache.org/jira/browse/SPARK-42856)
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    `./dev/run-tests` runs successfully
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No
    
    Closes #48871 from awadhesh14/master.
    
    Authored-by: awadhesh singh <[email protected]>
    Signed-off-by: Ruifeng Zheng <[email protected]>
    (cherry picked from commit cf502c656b71e0de8bfc4aea0fd2894dfd47cd9c)
    Signed-off-by: Ruifeng Zheng <[email protected]>
---
 .../src/main/scala/org/apache/spark/graphx/lib/LabelPropagation.scala   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/graphx/src/main/scala/org/apache/spark/graphx/lib/LabelPropagation.scala 
b/graphx/src/main/scala/org/apache/spark/graphx/lib/LabelPropagation.scala
index 7381f59771a4..9d4af50474a8 100644
--- a/graphx/src/main/scala/org/apache/spark/graphx/lib/LabelPropagation.scala
+++ b/graphx/src/main/scala/org/apache/spark/graphx/lib/LabelPropagation.scala
@@ -62,7 +62,7 @@ object LabelPropagation {
       map
     }
     def vertexProgram(vid: VertexId, attr: Long, message: Map[VertexId, 
Long]): VertexId = {
-      if (message.isEmpty) attr else message.maxBy(_._2)._1
+      if (message.isEmpty) attr else message.maxBy{ case (key, value) => 
(value, key) }._1
     }
     val initialMessage = Map[VertexId, Long]()
     Pregel(lpaGraph, initialMessage, maxIterations = maxSteps)(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to