graphlava

Chapter 1

Graphs, and where they stop

A binary edge is the best tool for most facts. This chapter finds the facts it cannot hold, and names the four signs that a model has outgrown it.

The binary edge

A graph has vertices and edges, and each edge joins exactly two vertices. In RDF the edge is a triple: subject, predicate, object.

:alice :worksAt :acme .
:bob   :worksAt :acme .
:alice :knows   :bob .

This is a good model. It is easy to store (three columns), easy to index (sort by any column order), and easy to query (patterns join on shared variables). Most facts in an agent's memory are binary, and they should stay binary.

A meeting of three

Now the agent learns two things:

Each meeting has four parts: who called it, who attended, the topic, the day. Try to write the first one as binary edges:

:alice :met       :bob .
:alice :discussed :pricing .
:bob   :discussed :pricing .
:alice :metOn     "2026-11-20"^^xsd:date .

Add the second meeting the same way and read the result back:

EdgeWhich meeting?
:alice :met :bobfirst
:alice :met :carolsecond
:alice :discussed :pricingfirst, but nothing says so
:alice :discussed :hiringsecond, but nothing says so
:alice :metOn "2026-11-20"either
:alice :metOn "2026-11-21"either

The question "what did Alice and Bob talk about?" now has two answers, and one of them is wrong. The edges are all true. What is lost is the grouping: which four facts belong to one event.

The decomposition problem

This is the general problem. A relation with k parts, split into binary edges, keeps the parts and drops the fact that they belong together. There are three common patches, and each moves the problem somewhere else.

PatchWhat it doesWhat it costs
Edge properties (property graphs)Put topic and day on the :met edgeA property holds a value, not a node: :pricing becomes a string. A third attendee still needs a second edge.
Compound predicates:metAboutPricingOne predicate per combination; nothing can be queried by topic.
Application glueKeep a meeting table outside the graphTwo sources of truth that drift. Graph queries cannot see the table.

The fix that works is to make the meeting a thing. Give it an identity, and hang each part off it as a role:

e1 :agent  :alice .
e1 :target :bob .
e1 :topic  :pricing .
e1 :when   "2026-11-20"^^xsd:date .

That is a hyperedge, encoded as a node with role edges. Chapter 2 treats hyperedges properly, and chapter 5 compares the ways to store one.

The hypergraph wall

A hypergraph lets one edge join any number of vertices, so it holds the meeting directly. But in a hypergraph an edge is a set of vertices, not a vertex. It cannot appear inside another edge. That limit is called the hypergraph wall. You have hit it when you need any of these four things:

#SymptomIn the running example
1A statement about a relationship":alice :worksAt :acme has confidence 0.9 and came from :chat12."
2A relationship between relationships"Meeting e1 led to the decision to change prices."
3Rich properties on a relationship as a thing"e1 has minutes, a room and an outcome, and the outcome has an author."
4Nested meta-relationships"The agent believes that :chat12 reported that Alice works at Acme."

Symptom 1 alone already breaks plain triples, since a triple cannot be the subject of another triple. Symptoms 2 to 4 break hypergraphs too. Agent memory has all four. Confidence, provenance and belief are statements about statements, and episodes are groups of facts that are themselves talked about.

Grouping is primitive or derived. In a hyperedge the grouping is part of the structure. In a node with role edges the grouping is derived: you find it by following the edges from e1. Queries can return the same rows, but a store can only enforce "a meeting has exactly one agent" when it knows the group is one thing.

The way past

Two moves get past the wall, and the rest of this book is about them.

  1. Give every relationship an identity. Then a relationship can be the subject or object of another one. That is reification, and in a statement graph it costs nothing extra, because every statement already has an ID (chapters 4 and 6).
  2. Let a vertex stand for a group. A graph that is also a node can hold a subgraph and be talked about. That is a container (chapter 7).

A structure with both moves, applied to any depth, is a metagraph (chapter 3).

In graphlava. The binary fact :alice :worksAt :acme is one statement with a 64-bit ID. The meeting is designed to be one hyperedge record of type :Meeting with three node roles, stored once; its date is a literal property of the meeting. The confidence on the fact is an annotation whose subject is the statement's ID. The episode is a graph, which is also a node. Each of these gets its own chapter.

Takeaways