liveBook · Manning

Multilayer graph

As explained in Just Use Postgres!

A multilayer graph is a graph organized into layers in which higher layers contain sparser subsets of nodes that also occur in lower layers.

A multilayer graph organizes vector embeddings into progressively denser layers. Higher layers contain sparse node subsets, and every higher-layer node also appears below. section 8.5.2

Use the layered structure to narrow vector similarity searches:

  • Start at the highest, sparsest layer. section 8.5.2
  • Follow nodes closest to the query embedding while descending through denser layers. section 8.5.2
  • Finish at the lowest layer, where additional nearby embeddings produce the final results. section 8.5.2

Movie recommendation search

For “May the force be with you,” the search begins with four upper-layer movies, selects A New Hope and The Mandalorian, then focuses lower-layer traversal on Star Wars movies. A PostgreSQL HNSW index supports the query with vector cosine ordering. section 8.5.2

Figure 8.9 Sample HNSW index with movie embeddings
A diagram of a star wars character

AI-generated content may be incorrect.

Inspect the layered movie-embedding diagram, then compare it with the HNSW creation statement and execution plan. section 8.5.2

How Just Use Postgres! covers it

How deep it goes
Explains layer density, node inheritance, and descending traversal, then stops short of graph-construction internals.
Examples
Uses movie embeddings, Star Wars queries, a multilayer diagram, PostgreSQL SQL, and an execution plan.
What it assumes
Assumes vector embeddings and similarity ordering, while introducing multilayer traversal through a concrete movie-search scenario.
What you can do after
Operate HNSW-backed searches and interpret how layered traversal narrows candidate movies.
How it connects
Connects vector embeddings, HNSW indexes, vector similarity search, and approximate nearest-neighbor retrieval.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.