LIVE DEMO

From graph to space: similarity and recommendations

See FastRP turn a graph of people, drinks, events and places into a space where distance means similarity, then use it to find look-alikes, place a brand-new product and build a price ladder.

From graph to space: similarity and recommendations: See FastRP turn a graph of people, drinks, events and places into a space where distance means similarity, then use it to find look-alikes, place a brand-new product and build a price ladder.

This interactive demo needs WebGL. Read about it.

From graph to space: similarity and recommendationsOpen the full demo →

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

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.

Learn more