graphlava

Chapter 5

Modeling hyperedges

The meeting e1 has three roles and a date. This chapter stores it three ways: as role statements in a plain statement graph, as a graphlava hyperedge record, and as tiramemsu does it. Then it says when to pick which.

The hyperedge, as a role-labelled set (chapter 2):

e1 : Meeting = { agent: :alice, target: :bob, topic: :pricing }   when = 2026-11-20

A. Role statements in a statement graph

The portable encoding is the star expansion: a node for the meeting and one statement per role.

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

This works in any RDF store and in graphlava too. Every role statement has its own ID, so each one can be annotated at once. The costs:

B. graphlava's hyperedge record

graphlava's spec stores a hyperedge as one record plus an index entry per role filler. The roles are still visible to queries as statements, but they are not stored as statements.

Declare the type

Every hyperedge has a type, declared in the meta-model with an ordered list of roles. Each role has an IRI, a cardinality (one or many) and an optional node kind. When every role is one, the type is fixed-arity and records need no role IDs: a slot's position is its role.

Role fillers are always nodes (ADR 0028). A literal value of the meeting, such as its date, is not a role. It is a literal attribute: an inline property of e1, stored in props[e1] like any other property. The type may declare it next to the roles.

# sketch, syntax not final: the spec defines what is declared, not how it is written
hyperedge type :Meeting {
  :agent  one  node
  :target one  node
  :topic  one  node
  attribute :when xsd:date   # a literal attribute: an inline property of e, not a role
}

Writing a hyperedge whose roles do not match its type fails with HyperedgeShapeMismatch. Adding an optional role later rewrites nothing; removing a role or changing its cardinality is an online migration.

Write it

# sketch, syntax not final: lowers to the IR operation CreateHedge(:Meeting, roles)
create :Meeting { :agent :alice, :target :bob, :topic :pricing } :when "2026-11-20"^^xsd:date
# returns a hyperedge ID, e1 (kind tag 0x6); :when is written to props[e1]

What is stored

hedge e1 type :Meeting :alice:bob :pricing props[e1]:when 2026-11-20 incidence (:alice, :agent, :Meeting, e1) incidence (:bob, :target, :Meeting, e1) incidence (:pricing, :topic, :Meeting, e1)
One hedge record keyed by the hyperedge ID, and one incidence key per node filler. The date is a literal attribute in props[e1] (dashed), not in the record, and gets no incidence key; finding meetings by date needs a value index on :when.
TableKeyValue
hedgeeversion, flags, role count k, type T, then k node IDs in declared role order (fixed arity) or k sorted (role, node) pairs (variable)
incidence(node, role, type, e)none

Hyperedge IDs come from chunks leased per home graph and type, so all meetings sit in a few ID ranges, and the type of any hyperedge can be read from its chunk without decoding the record.

Read it

Queries see the star expansion as role triples, (e, rdf:type, T) and (e, r, n). They are virtual: produced from hedge and incidence, never stored. The date is read like any inline property, as the triple (e1, :when, "2026-11-20").

PREFIX : <http://example.org/>
SELECT ?e ?topic ?when WHERE {
  ?e a :Meeting ; :agent :alice ; :target :bob ; :topic ?topic ; :when ?when .
}

With :alice bound, the plan is one incidence prefix scan on (:alice, :agent, :Meeting) and one hedge read per hit, plus one props[e1] read for :when. From v2, the spec has the planner collapse a star of role patterns of one fixed-arity type into a single scan of the type's records, with no join. In v0 the same pattern runs as a join of virtual role relations.

LookupAccess
hyperedge by IDhedge point read
all hyperedges of type TT's chunk ranges over hedge
where does n fill any role?incidence prefix (n)
where does n fill role r of type T?incidence prefix (n, r, T)

Change and delete it

Annotate one role

A role triple has no statement ID until something annotates it. Annotating it promotes it: the spec allocates a statement ID and stores a pointer in hedge_promo, keyed (e, role, node). The role stays served from the record.

# how sure are we that Alice called the meeting?
INSERT { ?e :agent :alice {| :confidence 0.7 |} }
WHERE  { ?e a :Meeting ; :agent :alice ; :target :bob }

Cost

Encoding of e1Base-table writesChange the topicShape checked
A. node + 5 role statements177 (3 deletes, 3 inserts, stmt)only by a shape
B. hyperedge record + date property5 (1 hedge + 3 incidence + 1 props)3 (1 slot, 1 key out, 1 key in)always, against the type

Write counts follow the operation table in the data model spec: 4 writes per node-valued statement, 1 per inline property. In A that is four node-valued statements (type and three roles) plus the date. Times are still to be measured.

C. What tiramemsu does

tiramemsu, the sibling store, has no hyperedge record. A row has exactly two ends, so it offers two patterns:

# when the relationship is the main thing: a node with roles
INSERT DATA { v:m1 a v:Meeting ; v:participant v:alice, v:bob, v:carol ; v:decided v:d1 . }

# when there is a natural binary core: annotate the edge
INSERT DATA { v:alice v:meets v:bob {| v:with v:carol ; v:with v:dave |} }

The second pattern gives the extra ends the edge's own lifetime and cascade. A typed layer, (v:with sys:subjectType sys:STMT), rejects a role written on a plain node by mistake. tiramemsu rejected content-addressed hyperedges, whose ID is a hash of the members, because they cannot say the same meeting happened twice. graphlava's allocated hyperedge IDs make the same choice.

The binary-core pattern also works in graphlava: :alice :met :bob {| :topic :pricing |} stores the topic as an annotation on the statement's ID.

Directed hyperedges and set-to-set edges

Direction is a property of roles, not of the store. A directed hyperedge (tail, head) is a type with a "from" role and a "to" role. A Basu–Blanning metaedge, set to set, is the same type with both roles of cardinality many, which graphlava stores in the variable record:

# sketch, syntax not final
hyperedge type :Handover { :from many node   :to many node }
create :Handover { :from :alice, :from :bob, :to :carol }

When to choose which

SituationChoose
Fixed roles, many instances, star queries (meetings, enrolments, transactions)graphlava hyperedge type
Roles vary a lot per instance, or the data must stay portable RDFA: node + role statements
One binary fact with a few qualifiersBinary statement with annotations
Most roles will carry their own annotationsA, or a hyperedge with promoted roles

In graphlava. A hyperedge is one record of a declared type, indexed once per node filler. Literal values such as a date are inline properties of the hyperedge, not roles. Queries see role triples that cost nothing to store. Roles are checked against the type, updates keep the hyperedge ID, deleting a filler needs DETACH, and annotating a role promotes just that role.

Contents