What you are looking at
Six people, Ada, Ben, Cara, Dev, Eli and Fay, and the things they do: the events they go to, the drinks they order and how often, what those drinks are made of, where events happen and the coffee they buy. It is one graph, so a drink, an event and a person can all be compared.
A graph answers direct questions superbly: who came to the tasting evening? Follow the relationships. It is weaker at who is like Ada?, because there is no relationship called "like".
FastRP fixes that. It starts every node at a random point, then moves each one towards the weighted average of its neighbours, and does it again. Connected things end up close together, and every node gets a list of numbers, its embedding. Store the embeddings, index them, and how alike are these two things? becomes a fast lookup.
The embeddings in this demo are computed in your browser, from the sample graph, with the same steps and settings as the Cypher shown beside it. Every ranking and score on screen comes from them. Nothing connects to a database.
Things to try
- Who is like Ada? Fay comes out on top: they share wine, espresso, gin, street art and jazz, and no one wrote a rule saying so.
- Invent the Espresso Martini. A new drink has no orders yet, but its ingredients have positions, so it has one too: halfway between coffee and vodka. The people nearest it are the ones to offer it to first.
- Coffee price ladder. Taste alone would happily recommend a $600 auction lot. Multiply taste by comfort with the price step and by the extra spend, and you get a ladder of comfortable steps instead.
- Mix two things (top right): pick any two, such as a place and an event, and see who sits nearest the combination.
In Galactus DB
CALL gds.fastRP.write('community', {
embeddingDimension: 64, iterationWeights: [0.0, 1.0, 1.0],
randomSeed: 42, writeProperty: 'embedding'
});
CREATE VECTOR INDEX embedding FOR (n:Person) ON (n.embedding)
OPTIONS {indexConfig: {`vector.dimensions`: 64, `vector.similarity_function`: 'cosine'}};
MATCH (me:Person {name: 'Ada'})
CALL db.index.vector.queryNodes('embedding', 4, me.embedding)
YIELD node, score
RETURN node.name, score;
The price ladder's comfort curve is an example written in plain Cypher arithmetic, not a built-in, and the prices are illustrative.
