Chapter 2
Hypergraphs
A hyperedge joins any number of vertices. This chapter defines it, adds direction and roles, and compares the encodings that keep the grouping with the one that throws it away.
Definition
A hypergraph is a pair H = (V, E). V is a set of vertices. E is a set of hyperedges, and each hyperedge is a non-empty subset of V.
V = { alice, bob, carol, pricing, hiring }
e1 = { alice, bob, pricing }
e2 = { alice, carol, hiring }
E = { e1, e2 }
Two numbers describe it. The cardinality of a hyperedge is how many vertices it joins (both have 3). The degree of a vertex is how many hyperedges contain it (Alice has 2, Bob has 1). A graph is the special case where every hyperedge has cardinality 2.
The two meetings from chapter 1 no longer mix: pricing is in e1 with Bob, hiring is in e2 with Carol.
Direction and roles
A plain hyperedge is a set, so it cannot say who called the meeting. Two refinements fix that.
A directed hyperedge is a pair of sets, a tail and a head: e = (T, H). A chemical reaction is the textbook case: ({H2, O2}, {H2O}). For a meeting, ({alice}, {bob}) says Alice met Bob.
Most data needs more than two sides. A role-labelled hyperedge maps role names to vertices:
e1 = { agent: alice, target: bob, topic: pricing, when: 2026-11-20 }
Direction is then just a convention on roles: the tail is the set of "from" roles, the head the set of "to" roles. Databases want this form. TypeDB's relations, the n-ary relation pattern in RDF and graphlava's hyperedge types are all role-labelled hyperedges. A role can also allow several vertices (a meeting with many attendees); chapter 5 calls that cardinality many.
The incidence matrix
The incidence matrix B has one row per vertex and one column per hyperedge. B[v][e] = 1 when v is in e.
| e1 | e2 | |
|---|---|---|
| alice | 1 | 1 |
| bob | 1 | 0 |
| carol | 0 | 1 |
| pricing | 1 | 0 |
| hiring | 0 | 1 |
Column sums are cardinalities; row sums are degrees. The matrix is useful for spectral analysis and clustering. As storage it is a poor fit: it is mostly zeros, and it has nowhere to put role names. Its useful part for a database is the list of non-zero cells read row by row, "which hyperedges does this vertex touch?". graphlava keeps exactly that list as its incidence index (chapter 5).
Encodings in a binary graph
Graph databases store binary edges, so a hyperedge has to be encoded. Three encodings are common.
Star expansion (the bipartite, or Levi, graph)
Add one node per hyperedge, and one edge from it to each member. The vertices form one partition, the hyperedge nodes the other, and every edge crosses between them. With role names on the edges, the encoding is lossless: you can rebuild the hypergraph exactly.
e1 :agent :alice .
e1 :target :bob .
e1 :topic :pricing .
e1 :when "2026-11-20"^^xsd:date .
This is the hub-and-spoke shape from chapter 1. Its price: a k-role hyperedge becomes k binary edges plus a node, and "the meeting" is found by following edges from the hub, not by reading one record.
Clique expansion
Join every pair of members with an edge. A k-member hyperedge becomes k(k-1)/2 edges, and the hyperedge itself is gone. One meeting of Alice, Bob and Carol, and three separate meetings of two, give the same triangle. Use clique expansion for analysis that only needs co-occurrence ("who has been in a room with whom"), never as storage.
Line graph
The dual view: hyperedges become vertices, joined when they share a member. e1 and e2 share Alice, so they are adjacent. It answers "which events share participants?" and is computed, not stored.
| Encoding | Keeps the grouping | Keeps roles | Size for k members | Use for |
|---|---|---|---|---|
| Incidence matrix | yes | no | |V| × |E| cells | spectral analysis |
| Star / bipartite | yes | yes, on spokes | 1 node + k edges | storage, traversal |
| Clique | no | no | k(k−1)/2 edges | co-occurrence analysis |
| Line graph | yes | no | computed | events that share members |
What a hyperedge still cannot do
In H = (V, E) a hyperedge is a subset of V. It is not in V. So no hyperedge can contain e1, and nothing can say "e1 led to a decision". That is the wall from chapter 1, and it is built into the definition.
The star expansion quietly gets past it. The hub e1 is a node in the binary graph, so another edge can point at it. That is reification: the relationship has become a thing. Chapter 3 makes this the rule instead of a trick.
In graphlava. The spec stores a role-labelled hyperedge as one record holding its type and its role fillers, plus an incidence index keyed (node, role, type, e), which is the row-wise incidence matrix with roles. Queries see the star expansion as virtual role triples, ?e a :Meeting ; :agent ?a, without the spokes being stored as statements. And because e1 has an ID like any other term, it can be the subject of further statements.
Takeaways
- A hyperedge is a set of vertices; a role-labelled hyperedge is a map from roles to vertices. Databases want the second.
- Star expansion (bipartite) is lossless and is what every graph store ends up using. Clique expansion loses the grouping.
- A hyperedge is not a vertex, so a hypergraph alone cannot talk about its own edges.