-
Notifications
You must be signed in to change notification settings - Fork 914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting Directed Flag Causes NullPointerException #29
Comments
ReasonI had met same error when running Detail
val node2attr = triplets.map { case (src, dst, weight) =>
(src, Array((dst, weight)))
}.reduceByKey(_++_).map { case (srcId, neighbors: Array[(Long, Double)]) =>
var neighbors_ : Array[(Long, Double)] = neighbors.groupBy(_._1).map { case (group, traversable) =>
traversable.head
}.toArray
if (neighbors_.length > bcMaxDegree.value) {
neighbors_ = neighbors.sortWith{ case (left, right) => left._2 > right._2 }.slice(0, bcMaxDegree.value)
}
SolutionsTo solve the problem, some modules should be modified. The details is shown below:
val graph = Graph(indexedNodes, indexedEdges).mapVertices[NodeAttr] { case (vertexId, nodeAttr) =>
var path:Array[Long] = null
if (nodeAttr != null) { // add
val (j, q) = GraphOps.setupAlias(nodeAttr.neighbors)
val nextNodeIndex = GraphOps.drawAlias(j, q)
nodeAttr.path = Array(vertexId, nodeAttr.neighbors(nextNodeIndex)._1)
nodeAttr
}else{
NodeAttr() // create a new object
}
}
// add:.filter(x=>x._2.path.nonEmpty).
val examples = g.vertices.filter(x=>x._2.path.nonEmpty).cache
...
// add the condition: attr.dstNeighbors != null && attr.dstNeighbors.nonEmpty
iter.map { case (edge, (attr, pathBuffer)) =>
try {
if (pathBuffer != null && pathBuffer.nonEmpty && attr.dstNeighbors != null && attr.dstNeighbors.nonEmpty) {
val nextNodeIndex = GraphOps.drawAlias(attr.J, attr.q)
val nextNodeId = attr.dstNeighbors(nextNodeIndex)
s"$pathBuffer\t$nextNodeId"
} else {
pathBuffer //add
}
} catch {
case e: Exception => throw new RuntimeException(e.getMessage)
} Hope this can help you! Good luck! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Somehow the Spark implementation crashes whenever the directed flag is set to true.
I ran it with both the
karate.edgelist
example and some dummy two-edge graph.The exception is always raised at the same location inside
initTransitionProb
after thegraph has been loaded.
Cheers.
The text was updated successfully, but these errors were encountered: