Graph Model Fundamentals

Every world model is built from the same primitives: nodes representing entities, labeled edges representing relationships, and pattern queries that traverse both. Before building a spatial-temporal world model with confidence scoring and temporal replay, you need to understand these mechanics.

This guide builds a minimal entity graph — agents with roles, communication links, and formation membership — and shows the traversal and algorithm patterns that carry through to every real world model.

Create entities#

CREATE (a1:Agent {name: 'Scout-01', role: 'scout', status: 'active'})
CREATE (a2:Agent {name: 'Scout-02', role: 'scout', status: 'active'})
CREATE (a3:Agent {name: 'Relay-01', role: 'relay', status: 'active'})
CREATE (a4:Agent {name: 'Command-01', role: 'command', status: 'idle'})

Every node has a label (Agent) and properties. Properties are schema-optional — add them per-node as needed, no migration required.

Create relationships#

Relationships are first-class objects, not foreign keys computed at query time. They have a type, a direction, and their own properties.

-- Communication links
MATCH (a1:Agent {name: 'Scout-01'}), (a2:Agent {name: 'Scout-02'})
CREATE (a1)-[:COMMS_WITH {latency_ms: 12, signal_strength: 0.95}]->(a2)
 
MATCH (a1:Agent {name: 'Scout-01'}), (a3:Agent {name: 'Relay-01'})
CREATE (a1)-[:COMMS_WITH {latency_ms: 45, signal_strength: 0.72}]->(a3)
 
MATCH (a3:Agent {name: 'Relay-01'}), (a4:Agent {name: 'Command-01'})
CREATE (a3)-[:REPORTS_TO {priority: 1}]->(a4)
 
-- Formation membership
CREATE (f:Formation {name: 'Alpha', pattern: 'wedge'})
 
MATCH (a1:Agent {name: 'Scout-01'}), (f:Formation {name: 'Alpha'})
CREATE (a1)-[:MEMBER_OF {position: 'lead'}]->(f)
 
MATCH (a2:Agent {name: 'Scout-02'}), (f:Formation {name: 'Alpha'})
CREATE (a2)-[:MEMBER_OF {position: 'wing'}]->(f)

Traverse: who does Scout-01 communicate with directly?#

MATCH (a:Agent {name: 'Scout-01'})-[:COMMS_WITH]->(peer:Agent)
RETURN peer.name, peer.role

Traverse: 2-hop communication paths#

MATCH (a:Agent {name: 'Scout-01'})-[:COMMS_WITH*2..2]->(remote:Agent)
RETURN DISTINCT remote.name, remote.role

*2..2 matches exactly 2 hops. *1..3 matches 1, 2, or 3. Variable-length paths — no recursive CTE, no self-join.

Filter: all active agents in the Alpha formation#

MATCH (a:Agent {status: 'active'})-[:MEMBER_OF]->(f:Formation {name: 'Alpha'})
RETURN a.name, a.role

Combine property filters with graph traversal in a single pattern.

Shortest path through the communication graph#

MATCH p = shortestPath(
  (a:Agent {name: 'Scout-01'})-[:COMMS_WITH|REPORTS_TO*]-(c:Agent {name: 'Command-01'})
)
RETURN length(p), [n IN nodes(p) | n.name] AS path

Aggregate: fleet status#

MATCH (a:Agent)
RETURN a.status, count(*) AS count
ORDER BY count DESC

Graph algorithm: communication centrality#

CALL algo.pageRank()
YIELD nodeId, score
MATCH (a:Agent) WHERE id(a) = nodeId
RETURN a.name, a.role, score
ORDER BY score DESC

PageRank on the communication graph surfaces which agents are most critical to information flow — if Scout-01 drops out, which messages can still reach Command-01? This structural question has no answer in entity properties alone.

Optional: agents with no direct command path#

MATCH (a:Agent)
OPTIONAL MATCH (a)-[:COMMS_WITH|REPORTS_TO*]->(c:Agent {role: 'command'})
WHERE c IS NULL
RETURN a.name, a.role AS unreachable_from_command

Snapshot#

:snapshot ./agent-graph.json

These are the mechanics every world model builds on. The next step is adding what makes a world model a world model: spatial positions (spatially indexed), observation classes (observed / inferred / predicted), confidence scores, and temporal replay.

See Also#

Try it
Open ↗
Loading engine…