The schema closes valid node and edge shapes
Road endpoints, kinds, minutes, capacity, and open state are checked before graph work publishes.
Canonical Grid model
Closed kinds, typed views, immutable rewrites, declarative paths, partitions, bounded patterns, and fixed-point propagation.
What this model gives you
25 min to study · Source reviewed 2026-08-25
Continue with guided practiceExpected checkpoint
After loading the four-city, four-road graph with one closed edge.
Road endpoints, kinds, minutes, capacity, and open state are checked before graph work publishes.
The fastest route minimizes summed minutes while a second route maximizes bottleneck capacity.
Paths, community membership, bounded patterns, contraction, and min-plus propagation publish Graph or Frame handles.
MODEL "Native Graph V2"
DESCRIPTION "Closed kinds, typed views, immutable rewrites, declarative paths, partitions, bounded patterns, and fixed-point propagation."
VERSION "1.0.0"
TAGS "graph", "schema", "kind", "view", "rewrite", "path", "partition", "pattern", "fixpoint"
graph schema Roads {
node kind City
edge kind Road: City -> City
node.kind: string
edge.kind: string
edge.minutes: number
edge.capacity: number
edge.open: boolean
}
graph roads: Roads = GRAPH(
[
["node_id", "kind"],
["A", "City"],
["B", "City"],
["C", "City"],
["D", "City"]
] AS nodes,
"node_id" AS node_id,
["kind"] AS node_properties,
[
["edge_id", "from", "to", "kind", "minutes", "capacity", "open"],
["ab", "A", "B", "Road", 4, 20, TRUE],
["bc", "B", "C", "Road", 7, 8, TRUE],
["ac", "A", "C", "Road", 15, 30, FALSE],
["cd", "C", "D", "Road", 3, 12, TRUE]
] AS edges,
"edge_id" AS edge_id,
"from" AS from,
"to" AS to,
["kind", "minutes", "capacity", "open"] AS edge_properties,
TRUE AS directed
)
# A single selective scalar consumer lets Graph MIR fuse this view.
graph open_roads: Roads = roads {
edge road where road.open = TRUE
}
R1C1 = GRAPH_EDGE_COUNT(open_roads)
# Rewrites are immutable and publish only after the complete bounded edit set validates.
graph normalized: Roads = rewrite roads limit 100:
match (origin)-[closed where closed.open = FALSE]->(destination)
delete closed
R1C2 = GRAPH_EDGE_COUNT(normalized)
# Source expresses the objective. EXPLAIN shows the chosen physical kernel.
path fastest = path in roads from "A" to "D"
minimize sum(edge.minutes)
limit 8 AS hops
path resilient = path in roads from "A" to "D"
maximize min(edge.capacity)
limit 8 AS hops
R1C3 = fastest.cost
R1C4 = fastest.hops
frame fastest_nodes = fastest.nodes
frame fastest_edges = fastest.edges
partition communities = partition nodes of roads by community(
leiden AS method,
modularity(1 AS resolution) AS objective,
edge.capacity AS weight,
directed AS direction,
0 AS seed,
all AS hierarchy,
50 AS max_passes,
16 AS max_levels,
0.000000001 AS tolerance
)
frame community_membership = communities.members
frame community_summary = communities.summary
# Contraction consumes the resident partition, keeps cross-community edges as
# a deterministic multigraph, and exposes the quotient as another GraphHandle.
graph quotient = contract roads by communities
R1C5 = GRAPH_NODE_COUNT(quotient)
frame open_two_hop_routes = match roads limit 100:
(origin)-[first where first.open = TRUE]->(middle)-[second where second.open = TRUE]->(destination)
return origin as origin, middle as middle, destination as destination,
first.minutes as first_minutes, second.minutes as second_minutes
frame travel_minutes = fixpoint in roads:
using min_plus(edge.minutes AS weight)
along AS direction
1000000000 AS default
0 AS seed "A"
until max_delta < 0.000000001
within 16 iterations
END MODEL