Algorithm
node2vec
activeNeeds verification
Learns node embeddings by running biased second-order random walks and training a skip-gram model on them, trading off local and global structure.
Intuition
Treat random walks as sentences and nodes as words, then use word2vec; parameters p and q make walks more BFS-like or DFS-like.
Complexity
| Time | O(r · l · V) walk generation plus skip-gram training |
|---|---|
| Space | O(V · d) |
Python
from torch_geometric.nn import Node2Vec
model = Node2Vec(data.edge_index, embedding_dim=128, walk_length=20,
context_size=10, walks_per_node=10, p=1.0, q=1.0)Cypher (Neo4j GDS)
CALL gds.node2vec.stream('myGraph', {embeddingDimension: 128})
YIELD nodeId, embedding RETURN nodeId, embeddingProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(r · l · V) walk generation plus skip-gram training |
|---|---|
| Space complexity | O(V · d) |
Relationships
- Belongs to
- Introduced by
- Applied to
- Prerequisite of
- Part of
- Prerequisites
- Random walk on a graph(Concept)
- Implemented by
- Neo4j Graph Data Science(Library / framework)
- PyTorch Geometric (PyG)(Library / framework)