Concepts

Edges & Hyperedges

How relationships are stored in HyperMemory

Edges & hyperedges

Edges

An edge (relates_to record in SurrealDB) is a directed binary relationship between two nodes with:

FieldDescription
relationshipA natural-language label describing the connection
dataOptional JSON metadata (weights, status, timestamps)

Edges are canonicalized by the server — relationship labels are normalized for consistency.

Example edge

{
  "from": "person_sarah",
  "to": "project_phoenix",
  "relationship": "Sarah is the technical lead for Project Phoenix",
  "data": {"since": "2026-01"}
}

Hyperedges

A hyperedge connects three or more nodes in a single relationship. This is implemented as a hyperedge record with participates_in links to each member node.

Example hyperedge

{
  "nodes": ["person_sarah", "person_marcus", "project_phoenix", "event_q3_planning"],
  "relationship": "Sarah and Marcus presented the Phoenix roadmap at Q3 planning"
}

How relationships are created

At store timehm_store triggers background enrichment that automatically detects entities and creates relationships.

Explicitly — use the REST API endpoint POST /api/v1/memory/relationships to create edges between existing nodes.

Via update — use hm_update to modify relationships on a node.

Via ingesthm_ingest decomposes dense text into entities and their relationships in one LLM pass.

When to use 2 vs N nodes

SituationPattern
Two actors onlyBinary edge (2 nodes)
A decision, several stakeholders, a milestoneHyperedge (N nodes in one relationship)
Soft tag between two thingsBinary edge with a specific relationship label

Over-hyperedging — If removing one participant no longer changes the meaning of the relationship, you may not need a large hyperedge. Smaller edges can be easier to search and update.

Querying relationships

  • Hybrid search: hm_recall searches node descriptions, edge labels, and data fields using BM25, vector similarity, and regex.
  • Graph traversal: hm_find_related walks from a starting node with configurable traversal strategies (chain, decay, type-boosted).
  • REST endpoint: GET /api/v1/memory/relationships/{key} lists edges connected to a specific node.

Next steps