🚀 SaaS & AI — book a free roadmap call →
✦ AI & RAG apps that understand your business data →
⇄ Multi-marketplace order & inventory automation →
📅 Taking a limited number of new builds this quarter →
← All posts
AI / Graphs

Graph engineering explained simply: the tutorial for anyone who already knows RAG

If you have built anything with RAG, you already know the disappointment: your assistant answers easy questions beautifully and then falls apart on the one question that actually mattered. Graph engineering is the discipline that grew up around fixing exactly that failure — and since July 2026 it has been the loudest phrase in AI engineering. This tutorial explains it from first principles, with no graph-theory background assumed.

The 30-second version

  • Vector search finds things that sound like your question. A graph finds things that are connected to your answer.
  • Graph engineering means storing knowledge as nodes (things) and typed edges (named relationships) that an AI can walk, instead of a pile of text chunks ranked by similarity.
  • It wins decisively on multi-hop, historical and "summarise the whole corpus" questions — and loses on simple lookups, where it just costs more.
  • The hard part is not the graph algorithms. It is deciding what counts as the same thing.
  • Almost every system that works in production is hybrid: vectors to find the door, the graph to walk through it.

1. The question your RAG can't answer

Here is a real shape of question, using an online seller as the example. Someone new joins the team and asks:

The question

"Why did we stop selling on the German marketplace?"

The answer lives in three separate places, and no single document contains it:

Ask a vector-based RAG system this question and it will retrieve the chunks that sound most like the words "stop", "selling", "German marketplace". It might surface the decision record. It will almost certainly miss the chain — because similarity ranks each chunk on its own, and the reason lives in the links between them. The model gets three unrelated-looking paragraphs and writes something confident and incomplete.

This is called a multi-hop question: answering it requires following two or more relationships. Multi-hop is where flat retrieval structurally cannot help you, no matter how good your embeddings are. And multi-hop questions are exactly the ones people ask when the stakes are high.

VECTOR SEARCH ranks each chunk alone GRAPH TRAVERSAL follows named links chunk · 0.82"…returns window…" chunk · 0.79"…pause DE…" chunk · 0.71"…chargebacks…" ✕ 3 fragments, no reason INCIDENT · Mar POLICY · Apr DECISION · May DECISION · Jan triggered led_to supersedes ✓ a chain you can read as a reason
The same three documents. On the left they are three scores; on the right they are a causal chain the model can quote back to you.
↑ back to top

2. What a graph actually is (no maths required)

In plain English

A graph is just things and the named connections between them. The things are called nodes (a customer, an order, a policy, a person, a decision). The connections are called edges (ordered, works_at, supersedes, caused). That is the entire concept. Your family tree is a graph. A London tube map is a graph. Your org chart is a graph.

A knowledge graph is a graph built out of the facts in your business, where each edge is a small sentence: subject → predicate → object. "Incident #412 triggered Policy Review DE." "ADR-019 supersedes ADR-004." "Priya decided ADR-019."

Compare that to how RAG stores the same knowledge today: as paragraphs of prose, converted into long lists of numbers, with all the structure dissolved. Embeddings are wonderful at fuzzy meaning and hopeless at precise structure. A graph is the opposite. That is why they combine so well.

Mental model that sticks

Vector search is asking a librarian who has skim-read everything — fast, associative, occasionally confidently wrong. A graph is following the footnotes — slower, deliberate, and it shows its work.

↑ back to top

3. The one idea that makes the whole thing work: typed edges

This is the part beginners skip and then wonder why their graph is useless. There is an enormous difference between an edge that says "these two are related" and an edge that says "this one replaced that one."

An untyped link carries one bit of information: connected. A typed edge carries a verb. Watch what happens to our example when you strip the verbs out:

# untyped — the chain survives, the meaning dies
ADR-019  —  ADR-004        # which one replaced which? unknowable
INC-412  —  ADR-019        # did the incident cause it, or follow from it?

# typed — now a machine can reason, not just wander
ADR-019  supersedes   ADR-004
INC-412  triggered    ADR-019
ADR-019  decided_by   Priya
ADR-004  valid_until  "2026-05-14"

With verbs, an agent can answer "what is our current position on Germany?" by following supersedes to the end of the chain, and "why?" by following triggered backwards. Without verbs, it can only tell you these documents are somehow about each other — which is roughly what vector search already told you, at ten times the cost.

Rule of thumb

Keep your edge vocabulary small and controlled — eight to fifteen verbs for a first graph. A free-for-all where the extractor invents relates_to, is_connected_with and associated_with for the same relationship gives you three useless edges instead of one useful one.

A good starter vocabulary looks like this:

supersedescauseddepends_ondecided_byownsmentionspart_ofcontradictsvalid_fromvalid_until

↑ back to top

4. Three different things people mean by "graph engineering"

The term went viral in July 2026 and, as usually happens, immediately fragmented. When someone says "graph engineering", they mean one of three things. Knowing which saves you a lot of confused conversations.

MEANING 1

Knowledge graphs & GraphRAG

Your documents, turned into entities and typed relationships that retrieval walks at query time. The best-researched of the three, and the subject of most of this tutorial.

MEANING 2

Agent memory graphs

What an agent remembers across sessions, stored as a graph that tracks when each fact was true — so yesterday's answer doesn't overwrite last year's history.

MEANING 3

Orchestration graphs

The shape of a multi-agent system itself: typed nodes, typed transitions, checkpoints and human approval gates — a graph of work instead of one long loop.

Meaning 2 deserves a note, because it fixes something vector stores genuinely cannot do. A temporal knowledge graph keeps two timelines on every edge: when the fact was true in the world, and when your system found out. When a new fact contradicts an old one, you don't delete the old edge — you close its validity window. That single design choice is what lets one graph answer both "where does she work?" and "where did she work in 2024?"

Meaning 3 is really the next chapter of the story we told in loop engineering: once one agent's loop becomes several agents' work, the loop becomes a graph. The rules that matter there are simple — draw an edge only where real work flows through it, fan out in parallel then merge at one owned place, and put the human approval gate exactly where a mistake is expensive to undo.

↑ back to top

5. Building one: the nine stages

Here is the pipeline, in the order that actually works. The single most common mistake is starting at stage 4.

  1. Scope Pick one painful, repeated question. Not "all our knowledge". The graph gets its boundary from the question, not the other way round.
  2. Representation Decide what a node is. Documents? Claims? Real-world entities? A graph of documents answers "what links to what"; a graph of entities answers "what is true".
  3. Ontology Write down your node types and your ten-ish edge verbs — before any extraction. This document is the highest-leverage page in the whole project.
  4. Entities Extract the nodes from your sources with an LLM pass, keeping the source, offset and timestamp for every one.
  5. Relations Extract the typed edges. Force the model to choose from your vocabulary; reject anything outside it rather than letting it invent.
  6. Events Attach time. When did this become true, when did you learn it, and when did it stop being true? Undated facts age into lies.
  7. Quality gate Validate: unknown edge types, dangling targets, missing inverses, contradiction cycles. This is the step everyone omits and every failing graph is missing.
  8. Fusion Merge duplicates — the entity-resolution step. Do it before storing, not as a clean-up job later.
  9. Serve to LLMs Expose traversal as a tool the agent can call, and return citations with every path.
The order is the lesson

Model the domain before extracting. Fuse before storing. Verify at every stage. A graph built in the wrong order does not fail loudly — it quietly returns confident, well-cited nonsense, which is far worse.

Here is the same pipeline as code, in miniature:

# stage 3: the ontology is a hard constraint, not a suggestion
EDGES = {"supersedes", "caused", "depends_on",
         "decided_by", "mentions", "valid_until"}

def ingest(doc):
    ents  = extract_entities(doc)              # stage 4
    rels  = extract_relations(doc, EDGES)      # stage 5 — constrained
    rels  = [r for r in rels if r.type in EDGES]  # stage 7 — reject, don't repair
    ents  = resolve(ents, graph)               # stage 8 — the expensive part
    for r in rels:
        graph.add(r, source=doc.id,            # provenance on every edge
                     seen_at=doc.ingested_at,
                     valid_from=r.date)        # stage 6 — time, always
↑ back to top

6. What actually happens when someone asks a question

A common misconception is that GraphRAG replaces vector search. In practice the good systems use both, in sequence. Vectors are excellent at one job — finding where to start — and the graph is excellent at the other: working out what else belongs in the answer.

QUESTION"why did we…" VECTOR SEEDfind entry nodes TRAVERSEfollow typed edges RANK + TRIMfit the context LLM+ cites the agent decides how many hops to take — depth is a decision, not a constant
Hybrid retrieval. Vectors find the door; the graph decides which rooms belong in the answer; every path comes back as a citation.

The 2026 refinement worth knowing is agentic traversal: rather than hard-coding "expand two hops", you let the agent decide when it has enough. It stops early on a simple question and digs deeper on a tangled one — which is both cheaper and more accurate than a fixed depth.

↑ back to top

7. The scoreboard: where graphs win, and where they lose

Marketing decks about GraphRAG only show you the wins. Here is the honest picture from published, independent evaluations. Read the bottom two rows as carefully as the top three.

Question typeGraph-basedClassic vector RAGVerdict
Multi-hop reasoning53.4%42.9%Graph wins clearly
Corpus-wide synthesis
"what are the themes across all of this?"
64.4%51.3%Graph wins clearly
Temporal reasoning
"what was true last year?"
58.121.7Not a contest
Simple fact lookup60.1%60.9%A tie — so pay less
Tokens per query
(global search, original pipeline)
~331,000~880Vector wins by 100×+

Figures from independent GraphRAG benchmark evaluations published 2025–2026; exact numbers vary by benchmark and by system. Scores are comparable within a row, not across rows.

Read benchmarks with a raised eyebrow

One well-known graph system reported spectacular results in its own paper, then scored 6.6 F1 under independent evaluation against 59.8 for a leading alternative. The rule is simple and unglamorous: never trust a system evaluated only by its authors — including your own. Build a small gold-standard set of your real questions and measure on that.

The practical conclusion the field converged on in 2026 is routing: send simple lookups to vector search, send multi-hop, historical and synthesis questions to the graph. A system that graphs everything is paying a hundred times the price for a tie on most of its traffic.

↑ back to top

8. The cost nobody puts on the slide

Building a vector index is cheap: an embedding pass over ten thousand documents costs a few dollars. Building a knowledge graph means an LLM reads the corpus to pull out entities and relationships — the same corpus might cost fifty to a couple of hundred dollars on a small pipeline, and the original Microsoft GraphRAG design was reported to run into five figures on large enterprise datasets in 2024.

That number is what caused the most important design shift in the field. Newer approaches — the "lazy" family — flip the pipeline around:

EAGER (2024)

Think at index time

Read everything with an LLM up front: extract entities, cluster into communities, summarise each one. Beautiful results, brutal bill, and it goes stale the moment your docs change.

LAZY (2025–26)

Think at query time

Build a cheap structural graph up front with barely any LLM use, then spend the reasoning budget only on questions people actually ask. Reported to cut indexing cost to a fraction of a percent of the eager approach at comparable quality.

THE LESSON

You don't need to pre-compute meaning

A cheap graph plus smart traversal captures most of the value. Leading systems now answer hard multi-hop questions on the order of a thousand tokens each — not hundreds of thousands.

And the licence for your graph database is the small part of the cost. The real bill is source connectors, schema design, extraction, entity resolution, human review, permissions, keeping edges current, observability and evaluation. Budget for the maintenance, not the migration.

↑ back to top

9. The silent killer: entity resolution

If you remember one warning from this tutorial, make it this one. Entity resolution is deciding when two mentions refer to the same real thing. Is "S. Kaur", "Simran Kaur" and "simran.k@…" one person or three? Is "the DE marketplace" the same node as "Germany store"?

Get this slightly wrong and the error does not stay small — it compounds along every hop:

Accuracy per hop2-hop answer3-hop answer5-hop answer
99%98%97%95%
95%90%86%77%
85%72%61%44%

A "95% accurate" extractor sounds excellent until you ask a five-hop question and find that one answer in four is built on a broken link.

This reframes where the effort goes. The glamorous work is traversal algorithms; the work that decides whether your graph is trustworthy is boring identity management — canonical IDs, alias tables, human review on ambiguous merges, and a bias toward not merging when unsure. Over-merging two distinct customers is much harder to detect later than leaving them separate.

Shortcut worth knowing

Wherever your team already writes explicit links — wiki links between pages, ticket references, foreign keys in your database — entity resolution is already solved by construction. No fuzzy matching, no compounding error. A well-maintained internal wiki or a normalised database is most of a knowledge graph already; you are extracting far less than you think.

↑ back to top

10. Should you actually build one?

Graphs are not a free upgrade. Use this as a decision aid rather than a mandate. A pilot is worth running when at least two of these are true of a workflow that genuinely matters to your business — and it is a strong yes at four:

And be equally willing to say no. Skip the graph when:

Define the kill rule first

Before the pilot starts, write down what would make you stop: "if verified answer time doesn't drop by X, or reviewer effort doesn't fall, we shut it down." Pilots without a kill rule become permanent regardless of results.

↑ back to top

11. Your first graph, this weekend

You do not need a graph database, a cluster, or a budget to learn this properly. Here is a genuinely useful starter project:

  1. Pick one question your team asks monthly and currently answers by digging through five documents. Write the ideal answer by hand first — that is your gold standard.
  2. List the node types involved. Usually four or five: Decision, Incident, Policy, Person, Product. Write them down.
  3. Write ten edge verbs and stop. Resist the eleventh. supersedes, caused, owns, decided_by, depends_on, mentions, part_of, contradicts, valid_from, valid_until.
  4. Extract from twenty documents, not two thousand. Store the result as plain JSON rows of {from, type, to, source, date}. Postgres, SQLite or a file is fine — you do not need Neo4j to learn whether the idea works for you.
  5. Give the agent one tool: neighbours(node, edge_types, depth). Let it call that tool as many times as it wants and require it to cite every path it used.
  6. Compare against your gold answer, then against plain vector RAG on the same twenty documents. If the graph doesn't win on your question, you have learned something valuable for the price of a weekend.

Every hard lesson in this article shows up at that scale: you will invent an eleventh edge verb by Saturday afternoon, discover two nodes that are secretly the same thing by Sunday morning, and realise your extractor never recorded dates by Sunday evening. Far better to learn it on twenty documents than on twenty thousand.

↑ back to top

12. Glossary

Node
A thing in your world — a person, an order, a document, a decision.
Edge
A connection between two nodes. Useful ones carry a verb.
Typed edge
An edge whose relationship is named: supersedes, caused, owns. The difference between a machine that reasons and one that wanders.
Ontology
Your written list of allowed node types and edge verbs. The schema of your knowledge.
Multi-hop
A question that needs two or more relationships followed to answer. Where graphs earn their keep.
GraphRAG
RAG where the retrieval step traverses a graph instead of only ranking chunks by similarity.
Entity resolution
Deciding which mentions refer to the same real thing. The hardest and most under-budgeted part.
Community detection
Clustering densely-connected nodes so the system can summarise a whole region of the graph — how "what are the themes?" questions get answered.
Temporal graph
A graph where every edge records when a fact was true and when you learned it, so history survives updates.
Provenance
The source, timestamp and extraction method attached to an edge — what makes a citation possible.
Hybrid retrieval
Vector search to find entry points, graph traversal to expand from them. The pattern most production systems land on.

Frequently asked questions

Is graph engineering just a new name for knowledge graphs?
Largely yes — with an agent-shaped twist. Knowledge graphs are decades old. What is new is building them specifically so an AI agent can traverse them at query time, keeping them current as facts change, and treating graph design as an engineering discipline with its own costs, tests and failure modes. The term itself is young: it appeared in July 2026 and spread within days, following prompt engineering, context engineering and loop engineering along the same treadmill.
Do I need to throw away my vector database?
No, and you probably shouldn't. Nearly every system that works well in production is hybrid: vector search finds the entry points, graph traversal follows the relationships from there. Vectors still win on simple lookups and cost far less per query, so route the easy traffic to them and reserve the graph for questions that genuinely need it.
Which graph database should I use?
Defer that decision until you have proven the need. Neo4j, Neptune and the graph extensions on Postgres all work; for a first pilot, adjacency rows in the database you already run are entirely adequate. Choosing infrastructure before you have a validated question is the most common way these projects stall.
How big does my corpus need to be?
Smaller than you think. Graph value comes from connectedness, not volume. Two hundred densely cross-referenced internal documents will demonstrate the benefit far better than fifty thousand unrelated PDFs — and a huge but disconnected corpus is exactly the case where the graph costs a lot and returns little.
Can an LLM build the graph for me automatically?
It can do the extraction, and that is genuinely useful. It cannot decide your ontology, and it should not be trusted alone with entity resolution on anything that matters. Constrain it to your edge vocabulary, reject anything outside it, and put a human review step on ambiguous merges. Automatic extraction with no gate produces a large, confident, wrong graph.
How do I know it is actually working?
Build a gold-standard set of twenty to fifty real questions with verified answers, and measure precision and recall against it — before and after. Track how long a person takes to reach a verified answer, and how often a reviewer has to correct one. If those two numbers don't move, the graph is not paying for itself, whatever the demo looks like.

Where this leaves you

Graph engineering is not a replacement for everything you have built. It is the answer to one specific, expensive failure: questions whose answers live in the connections between your documents rather than inside any one of them. If you already run RAG over your business data and keep hitting the wall on "why", "since when" and "what changed" questions, that wall has a name now — and a well-mapped route around it.

Start with one question, ten edge verbs and twenty documents. Measure it honestly. Expand only where the graph earns its cost. That discipline — knowing when not to build the graph — is what separates graph engineering from graph enthusiasm.

Talk to us about your AI project

Loop engineering: stop prompting your AI, start designing the loop →