Skip to content

Commit

Permalink
fix npe for setting directed flag (#58)
Browse files Browse the repository at this point in the history
* fix npe for setting directed flag

* fix data struct
  • Loading branch information
Nicole00 authored Jan 5, 2023
1 parent 78713c1 commit 0e0668e
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,14 @@ object Node2vecAlgo {
graph = Graph(indexedNodes, indexedEdges)
.mapVertices[NodeAttr] {
case (vertexId, clickNode) =>
val (j, q) = this.setupAlias(clickNode.neighbors)
val nextNodeIndex = this.drawAlias(j, q)
clickNode.path = Array(vertexId, clickNode.neighbors(nextNodeIndex)._1)

clickNode
if (clickNode != null) {
val (j, q) = this.setupAlias(clickNode.neighbors)
val nextNodeIndex = this.drawAlias(j, q)
clickNode.path = Array(vertexId, clickNode.neighbors(nextNodeIndex)._1)
clickNode
} else {
NodeAttr()
}
}
.mapTriplets { edgeTriplet: EdgeTriplet[NodeAttr, EdgeAttr] =>
val (j, q) = this.setupEdgeAlias(bcP.value, bcQ.value)(edgeTriplet.srcId,
Expand Down Expand Up @@ -210,11 +213,14 @@ object Node2vecAlgo {
.map {
case (edge, ((srcNodeId, pathBuffer), attr)) =>
try {
val nextNodeIndex = this.drawAlias(attr.J, attr.q)
val nextNodeId = attr.dstNeighbors(nextNodeIndex)
pathBuffer.append(nextNodeId)

(srcNodeId, pathBuffer)
if (pathBuffer != null && pathBuffer.nonEmpty && attr.dstNeighbors != null && attr.dstNeighbors.nonEmpty) {
val nextNodeIndex = this.drawAlias(attr.J, attr.q)
val nextNodeId = attr.dstNeighbors(nextNodeIndex)
pathBuffer.append(nextNodeId)
(srcNodeId, pathBuffer)
} else {
(srcNodeId, pathBuffer)
}
} catch {
case e: Exception => throw new RuntimeException(e.getMessage)
}
Expand Down

0 comments on commit 0e0668e

Please sign in to comment.