Comments (1)
Reason
I had met same error when running val (j, q) = GraphOps.setupAlias(nodeAttr.neighbors)
in GraphOps.initTransitionProb, This is due to the nodeAttr
object being Null.
Detail
- Some
dst
nodes should be included in thenode2attr
object but not in the following code:
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)
}
- Then when creating graph object by
val graph = Graph(indexedNodes, indexedEdges)
, thedst
nodes mentioned above, which are missing, will be created by default. And the format by default is [vertexId, Null] ,instead of [vertexId, NodeAttr]. So the error come.
Solutions
To solve the problem, some modules should be modified. The details is shown below:
- GraphOps.initTransitionProb
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
}
}
- Node2Vec.randomWalk
// 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!
from node2vec.
Related Issues (20)
- Where can i find the code of link prediction task mentioned in the paper?
- [node2vec_spark]Could somebody explain what this code is doing? HOT 1
- Saving corpus in text file
- Is it possible to run node2vec on multi graphs ? HOT 3
- comparison of GCN and node2vec
- For large weighted graph the preprocess_transition_probs is very slow
- Can node2vec be used in Chinese? A data format similar to my following? HOT 1
- ./node2vec: No such file or directory
- Error in "karate.edgelist"
- Qusetion:How to input weight graph?
- how to use node2vec in community detection
- ModuleNotFoundError: No module named 'node2vec', even after 'pip install node2vec'
- Confusion with BFS and DFS
- im recieving this error HOT 1
- Can we use any technique other than word2vec in the implementation of node2vec for finding embeddings?
- Errors trying to run under Python3 HOT 2
- Nothing happened then after running node2vec HOT 2
- What is `alias_nodes` and `alias_edges` for? HOT 1
- Can I change the initial state of the embeddings?
- org.apache.parquet.schema.Types$GroupBuilder cannot be cast to org.apache.parquet.schema.Types$BaseGroupBuilder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node2vec.