diff --git a/graph/src/main/scala/org/apache/spark/graph/impl/GraphImpl.scala b/graph/src/main/scala/org/apache/spark/graph/impl/GraphImpl.scala
index 09aeade8c12bef113d9bbc83f6ce085cfa9cd0e7..db982a8fe4b9ea9acab3c5afd47f1c4f395bc3f9 100644
--- a/graph/src/main/scala/org/apache/spark/graph/impl/GraphImpl.scala
+++ b/graph/src/main/scala/org/apache/spark/graph/impl/GraphImpl.scala
@@ -471,7 +471,7 @@ object GraphImpl {
    * random vertex cut.
    */
   protected def randomVertexCut(src: Vid, dst: Vid, numParts: Pid): Pid = {
-    math.abs((src, dst).hashCode()) % Pid
+    math.abs((src, dst).hashCode()) % numParts
   }