Skip to content

Commit 5900c22

Browse files
committed
Round X in loop condition
1 parent 6fd5fb1 commit 5900c22

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

graphx/src/main/scala/org/apache/spark/graphx/util/GraphGenerators.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ object GraphGenerators {
114114
// Z ~ N(0, 1)
115115
var X: Double = maxVal
116116

117-
while (X >= maxVal) {
117+
while (round(X) >= maxVal) {
118118
val Z = rand.nextGaussian()
119119
X = math.exp(mu + sigma*Z)
120120
}
121-
math.floor(X).toInt
121+
round(X)
122122
}
123123

124+
private def round(x: Double): Int = math.round(x.toFloat)
125+
124126
/**
125127
* A random graph generator using the R-MAT model, proposed in
126128
* "R-MAT: A Recursive Model for Graph Mining" by Chakrabarti et al.

0 commit comments

Comments
 (0)