Graph Embeddings with GDS
Learn how Graph Data Science generates node embeddings that turn graph structure into vectors for machine learning.
Graph Embeddings with GDS is a free Neo4j Graph Database Fundamentals lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Neo4j Graph Database Fundamentals learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
From Graphs to Vectors
Machine learning models work with numbers, not graph topology. Graph embeddings convert each node into a fixed-length vector that captures its position and neighborhood.
Why Embeddings Help
Once nodes are vectors, you can feed them into classifiers, clustering, and similarity search. Similar nodes end up close together in vector space.
Projecting a Graph
Embeddings run on an in-memory graph projection in GDS. First project the nodes and relationships you care about.
CALL gds.graph.project(
'embedGraph',
'Person',
'FRIEND'
);FastRP
FastRP (Fast Random Projection) is a quick, scalable embedding algorithm. It is a great default for large graphs.
CALL gds.fastRP.stream('embedGraph', { embeddingDimension: 128 })
YIELD nodeId, embedding
RETURN gds.util.asNode(nodeId).name AS name, embedding
LIMIT 5;Node2Vec
Node2Vec uses biased random walks to learn embeddings that balance local and global structure. It is slower but often richer than FastRP.
CALL gds.node2vec.stream('embedGraph', { embeddingDimension: 128, walkLength: 80 })
YIELD nodeId, embedding
RETURN nodeId, embedding
LIMIT 5;GraphSAGE
GraphSAGE is an inductive method: it learns a function that can embed even new nodes not seen during training, using their features.
Choosing Dimensions
The embedding dimension trades expressiveness for cost. Common values are 64, 128, or 256. Larger is more detailed but heavier.
Writing Embeddings Back
Use the write mode to store embeddings as a node property, so other queries and tools can use them.
CALL gds.fastRP.write('embedGraph', {
embeddingDimension: 128,
writeProperty: 'embedding'
});Using Embeddings for Similarity
With vectors stored, compute cosine similarity between embeddings to find nodes that are structurally alike.
MATCH (a:Person {name: 'Alice'}), (b:Person)
WHERE a <> b
RETURN b.name, gds.similarity.cosine(a.embedding, b.embedding) AS sim
ORDER BY sim DESC LIMIT 5;Embeddings in ML Pipelines
Embeddings are powerful features for GDS machine learning pipelines: node classification and link prediction both benefit from them.
Choosing an Algorithm
Use FastRP for speed at scale, Node2Vec for richer structure, and GraphSAGE when you must embed unseen nodes.
Quick Check
Test your embeddings knowledge.
Recap
You learned graph embeddings in GDS:
- Embeddings turn nodes into vectors
- FastRP is fast and scalable
- Node2Vec uses biased random walks
- GraphSAGE handles unseen nodes
- Write embeddings back and use them in ML pipelines
Frequently asked questions
Is the “Graph Embeddings with GDS” lesson free?
Yes — the full text of “Graph Embeddings with GDS” is free to read here on the web, and the Neo4j Graph Database Fundamentals course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Neo4j Graph Database Fundamentals course, upgrade to CoddyKit PRO.
What will I learn in “Graph Embeddings with GDS”?
Learn how Graph Data Science generates node embeddings that turn graph structure into vectors for machine learning. You practise Neo4j Graph Database Fundamentals with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Neo4j Graph Database Fundamentals?
No prior experience is required. Neo4j Graph Database Fundamentals on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Graph Embeddings with GDS” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Neo4j Graph Database Fundamentals lesson?
Yes. Every Neo4j Graph Database Fundamentals lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to GDS Library
- Running GDS Algorithms
- GDS Pipelines and Machine Learning
- Graph Embeddings with GDS