If you are using Neo4j 4, you are able to use the 1.3 release of the GDS that comes with a few node embedding algorithms. In particular, you can run the node2vec algorithm inside Neo4j. The output of the embedding procedures are the node embeddings themselves. As with any other procedures of the GDS, you first have to create a projected graph, and then you can extract embedding for the nodes in this projected graph with the following query:
CALL gds.alpha.node2vec.stream("projected_graph")
The node2vec procedure returns the embedding vector for each node. You can configure random walks and model training with the configuration map. For instance, let's change the embedding size from 100 (default value) to 20, and the number of generated random walks for each node from 10 to 2:
CALL gds.alpha.node2vec.stream(“MyGraph”, {walksPerNode: 2, embeddingSize: 10})
Let's now see how the results of these procedures can be used...