node2vec icon indicating copy to clipboard operation
node2vec copied to clipboard

The first walk path problem in spark-version

Open datazhen opened this issue 7 years ago • 2 comments

The first walk path of each nodes is unchanging after init in Node2Vec.initTransitionProb module.

 graph = Graph(indexedNodes, indexedEdges)
            .mapVertices[NodeAttr] { case (vertexId, clickNode) =>
              val (j, q) = GraphOps.setupAlias(clickNode.neighbors)
              val nextNodeIndex = GraphOps.drawAlias(j, q)
              clickNode.path = Array(vertexId, clickNode.neighbors(nextNodeIndex)._1)
              
              clickNode
            }

Therefor it result that the first path of a node from each walkers is same.


    for (iter <- 0 until config.numWalks) {
      var prevWalk: RDD[(Long, ArrayBuffer[Long])] = null
      var randomWalk = graph.vertices.map { case (nodeId, clickNode) =>
        val pathBuffer = new ArrayBuffer[Long]()
        pathBuffer.append(clickNode.path:_*)
        (nodeId, pathBuffer) 
      }.cache

In particular at the setting of directed=true, the edges is so sparse that it‘s hard to come back.

datazhen avatar Apr 27 '18 17:04 datazhen

There is random function in GraphOps.drawAlias(j, q), why the first walk path is unchanging?

celia01 avatar Nov 27 '18 07:11 celia01

I found this problem too. The first walk will not change after initialization.

wl142857 avatar Mar 05 '19 10:03 wl142857