Graph commands

31 commands. Each entry gives the invocation and an example, in the interface you pick; open the details for parameters, return shape and error codes.

apply_delete_policy

Apply a delete policy to bound graph facts.

db.graphs.apply_delete_policy(primitive: 'str', key: 'str', policy: 'str', *, space: 'Optional[str]' = None) -> 'Any'

Applies an explicit policy to every graph node bound to the given entity target: `cascade` deletes the bound nodes and their incident edges, `detach` keeps the nodes but removes their bindings, and `keep_dangling` preserves the bindings so traversal can report the target's status. The acknowledgement reports how many bound nodes the policy covered.

To see the complete help for this command, run:

help(db.graphs.apply_delete_policy)

Example

_ = db.graphs.create("kb")_ = db.graphs.add_node("kb", "ada", binding={"target": {"primitive": "kv", "space": "default", "key": "user:1"}})_ = db.graphs.apply_delete_policy("kv", "user:1", "cascade")  # cascade removes the bound node and its incident edges.db.graphs.get_node("kb", "ada") is None
View details →

batch_write

Apply graph mutations atomically.

db.graphs.batch_write(graph: 'str', operations: 'list') -> 'Any'

Applies a list of graph operations - `upsert_node`, `delete_node`, `upsert_edge`, `delete_edge` - in one engine commit. Validation failures (bad ids, missing edge endpoints, frozen-ontology violations) reject the whole batch; nothing is partially applied. The response reports one positional item result per operation, all sharing the same commit receipt.

To see the complete help for this command, run:

help(db.graphs.batch_write)

Example

_ = db.graphs.create("g")_ = db.graphs.batch_write("g", [{"type": "upsert_node", "node_id": "a", "data": {"object_type": "person"}}, {"type": "upsert_node", "node_id": "b", "data": {"object_type": "person"}}, {"type": "upsert_edge", "src": "a", "edge_type": "knows", "dst": "b", "data": {}}])  # All operations land in one engine commit, or none do.db.graphs.meta("g").node_count
View details →

bindings

Find graph nodes bound to an entity.

db.graphs.bindings_for_entity(primitive: 'str', key: 'str', *, space: 'Optional[str]' = None, as_of: 'Optional[int]' = None, as_of_time: 'Optional[TimeLike]' = None) -> 'Page'

Searches every graph in the selected branch and space for nodes whose entity binding matches the given target (primitive, space, key). This is the reverse index of node bindings: given an entity, find the graph facts attached to it. Results paginate by an opaque cursor.

To see the complete help for this command, run:

help(db.graphs.bindings_for_entity)

Example

_ = db.graphs.create("kb")_ = db.graphs.add_node("kb", "ada", binding={"target": {"primitive": "kv", "space": "default", "key": "user:1"}})  # Bind the node to a KV entity so retrieval can cross primitives.[h.node_id for h in db.graphs.bindings_for_entity("kv", "user:1")]
View details →

bulk_insert

Bulk-load nodes and edges in chunks.

strata graph bulk-insert

Ingests a payload of nodes and edges in chunked commits: nodes first, then edges, so edges may reference nodes from the same payload. Node objects use the key `node_id`; edges use `src`, `edge_type`, `dst`, and optional `weight` (default 1.0) and `properties`. `chunk_size` bounds items per commit (default 512, clamped at 800). The acknowledgement reports inserted counts, the number of chunk commits, and the final chunk's commit receipt.

To see the complete help for this command, run:

strata graph bulk-insert --help

Example

strata graph create gcreated graph gstrata command run --command-json '{"edges":[{"dst":"b","edge_type":"knows","src":"a"}],"graph":"g","nodes":[{"node_id":"a","object_type":"person"},{"node_id":"b","object_type":"person"}],"type":"graph_bulk_insert"}'inserted 2 nodes, 1 edge into gstrata graph meta ggraph            gnode_count       2edge_count       1created_version  3updated_version  5import_pending   false
View details →

create

Create a named graph.

strata graph create

Creates an empty named graph in the selected space and returns its metadata, including node and edge counts (zero at creation) and the create commit coordinates. A database can hold many graphs; graph names are unique per branch and space. Creating a name that already exists fails with `already_exists.engine.graph`.

To see the complete help for this command, run:

strata graph create --help

Example

strata graph create socialcreated graph socialstrata graph listsocial
View details →

delete

Delete a graph and its visible data.

strata graph delete

Deletes a named graph and every visible node, edge, binding, and ontology row it owns. Deleting a graph that does not exist is not an error: the acknowledgement reports `deleted: false` with a `not_found` effect. Earlier states remain readable through time travel on other commands.

To see the complete help for this command, run:

strata graph delete --help

Example

strata graph create tempcreated graph tempstrata graph delete tempdeleted graph tempstrata graph list(empty)
View details →

list

List graph names.

strata graph list

Lists graph names in lexicographic order. Accepts an optional item limit (default 100), an exclusive name cursor for continuation, and an `as_of` timestamp to list the graphs visible at an earlier instant.

To see the complete help for this command, run:

strata graph list --help

Example

strata graph create socialcreated graph socialstrata graph listsocial
View details →

meta

Read graph metadata and counts.

strata graph meta

Reads a graph's metadata: live node and edge counts, the create and last-update commit versions and timestamps, and `import_pending` - whether a `bulk_insert` spanning more than one commit began and has not finished (its first commit sets the flag, its last clears it, so an interrupted import leaves it set; re-running the import clears it). This is one row read, not a scan: the graph's metadata row carries its counts and is rewritten by every commit that changes a node or edge, so `updated_version` is a per-graph revision token - unchanged means no node or edge has changed since, whatever else moved on the branch. Ontology changes do not move it. Reading a graph that does not exist returns no data rather than an error. Accepts `as_of` for time travel. A graph whose rows were last written by a release before its metadata row carried counts is counted by scan until its next write.

To see the complete help for this command, run:

strata graph meta --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph meta socialgraph            socialnode_count       2edge_count       0created_version  3updated_version  5import_pending   false
View details →

neighbors

List a node's neighbors.

strata graph neighbors

Walks a node's edges and returns one hit per traversed edge. Direction is `outgoing`, `incoming`, or `both`; an optional edge-type filter restricts the walk. Each hit embeds both the traversed edge and the neighbor node in full, so a follow-up read is rarely needed. A missing node yields an empty page.

To see the complete help for this command, run:

strata graph neighbors --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph add-edge social alice knows bobcreated edge alice -[knows]-> bob in socialstrata graph neighbors social alice --direction outgoingNODE_ID  DIRECTION  EDGE_TYPE  SRC    DST  WEIGHTbob      outgoing   knows      alice  bob     1.0
View details →

nodes_by_type

List nodes declaring an object type.

strata graph nodes-by-type

Lists the nodes that declare a given object type, in node-id order. The type index is maintained from each node's declared `object_type`, so this works whether the ontology is draft or frozen. Accepts a limit, an exclusive cursor, and `as_of` for time travel.

To see the complete help for this command, run:

strata graph nodes-by-type --help

Example

strata graph create gcreated graph gstrata graph add-node g a --type personcreated node a in gstrata graph add-node g b --type personcreated node b in gstrata graph nodes-by-type g personNODE_ID  OBJECT_TYPE  VERSIONa        person             …b        person             …
View details →

sample

Sample graph nodes.

strata graph sample

Returns a deterministic representative sample of nodes from a graph: the total live node count and up to `count` nodes (default 10), evenly strided over the ordered node ids. Latest state only.

To see the complete help for this command, run:

strata graph sample --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph sample gNODE_ID  OBJECT_TYPE  VERSIONa        -                  …b        -                  …
View details →

Analytics

analytics bfs

Run a bounded breadth-first traversal.

strata graph bfs

Runs a breadth-first traversal from a start node over a consistent snapshot, bounded by `max_depth` (default 100) and `max_nodes` (default 10000). Returns visited node ids in traversal order, a depth per node, and the tree edges in discovery order. Direction defaults to `outgoing`; an optional edge-type list restricts every hop. The start node must exist (`not_found.engine.graph_node`).

To see the complete help for this command, run:

strata graph bfs --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph bfs g a --direction outgoingNODE  DEPTHa         0b         1c         2
View details →

analytics cdlp

Detect communities via label propagation.

strata graph cdlp

Detects communities by label propagation over a consistent snapshot: every node repeatedly adopts the most common label among its neighbors until labels stabilize or the iteration bound (default 10) is reached. Every node maps to its community representative node id. Propagation direction defaults to `both`. Accepts an optional snapshot budget and `as_of` for time travel.

To see the complete help for this command, run:

strata graph cdlp --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph cdlp g --direction bothNODE  LABELa     ab     bc     a
View details →

analytics lcc

Compute local clustering coefficients.

strata graph lcc

Computes the local clustering coefficient for every node over a consistent snapshot: the fraction of a node's neighbor pairs that are themselves connected. Nodes in fully-triangulated neighborhoods score 1.0. Accepts an optional snapshot budget and `as_of` for time travel.

To see the complete help for this command, run:

strata graph lcc --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph lcc gNODE  COEFFICIENTa             0.0b             0.0c             0.0
View details →

analytics pagerank

Compute PageRank importance scores.

strata graph pagerank

Computes PageRank over a consistent snapshot. Tunable damping (default 0.85), iteration bound (default 20), and convergence tolerance (default 1e-6); the response reports how many iterations actually ran. Optional personalization seeds steer both teleport and dangling mass toward weighted nodes, and the response flags `personalized: true`. Results are deterministic for a fixed graph state. Accepts an optional snapshot budget and `as_of` for time travel.

To see the complete help for this command, run:

strata graph pagerank --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph pagerank gNODE  RANKc     0.474412b     0.341171a     0.184417
View details →

analytics sssp

Compute shortest-path distances from a source.

strata graph sssp

Computes weighted shortest-path distances from a source node over a consistent snapshot, and for every reachable node the predecessor its cheapest walk arrived from - follow `predecessors` back to the source to unpack a path. Edge weights (default 1.0) accumulate along paths; unreachable nodes are omitted from the result. Direction defaults to `outgoing`. `edge_types` restricts the walk to the listed types (a type the graph does not contain restricts to nothing, as for `bfs`); a negative-weight edge among the selected types refuses with `failed_precondition.engine.graph_negative_weight`. The source node must exist (`not_found.engine.graph_node`). Accepts an optional snapshot budget and `as_of` for time travel.

To see the complete help for this command, run:

strata graph sssp --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph sssp g a --direction outgoingNODE  DISTANCE  VIAa          0.0  -b          1.0  ac          2.0  b
View details →

analytics wcc

Compute weakly connected components.

strata graph wcc

Computes weakly connected components over a consistent snapshot of the graph, ignoring edge direction. Every node maps to its component representative - the smallest node id in its component - and the response carries the distinct component count. Accepts an optional snapshot budget and `as_of` for time travel.

To see the complete help for this command, run:

strata graph wcc --help

Example

strata graph create gcreated graph gstrata graph add-node g acreated node a in gstrata graph add-node g bcreated node b in gstrata graph add-node g ccreated node c in gstrata graph add-edge g a knows bcreated edge a -[knows]-> b in gstrata graph add-edge g b knows ccreated edge b -[knows]-> c in gstrata graph wcc gNODE  COMPONENTa     ab     ac     a
View details →

Edges

edge add

Add or replace a graph edge.

strata graph add-edge

Adds a directed edge `src -[edge_type]-> dst` or replaces it if the same triple already exists. Both endpoints must already exist; writing an edge to a missing node fails with `invalid_argument.engine.graph_edge_endpoint`. Weight defaults to 1.0 and must not be negative. Once the graph's ontology is frozen, the edge type and its endpoint object types are validated against the declared link types.

To see the complete help for this command, run:

strata graph add-edge --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph add-edge social alice knows bobcreated edge alice -[knows]-> bob in socialstrata graph get-edge social alice knows bobsrc         aliceedge_type   knowsdst         bobgraph       socialweight      1.0properties  -version     …
View details →

edge get

Read one graph edge.

strata graph get-edge

Reads one edge by its `(src, edge_type, dst)` triple, returning its weight, properties, and last-write commit coordinates. A missing edge reads back as no data. Accepts `as_of` for time travel.

To see the complete help for this command, run:

strata graph get-edge --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph add-edge social alice knows bobcreated edge alice -[knows]-> bob in socialstrata graph get-edge social alice knows bobsrc         aliceedge_type   knowsdst         bobgraph       socialweight      1.0properties  -version     …strata graph get-edge social alice knows absent(nil)
View details →

edge remove

Remove a graph edge.

strata graph remove-edge

Removes one directed edge by its `(src, edge_type, dst)` triple. The endpoints are untouched. Removing an edge that does not exist is not an error: the acknowledgement reports `deleted: false`.

To see the complete help for this command, run:

strata graph remove-edge --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph add-edge social alice knows bobcreated edge alice -[knows]-> bob in socialstrata graph remove-edge social alice knows bobdeleted edge alice -[knows]-> bob in socialstrata graph get-edge social alice knows bob(nil)
View details →

Nodes

node add

Add or replace a graph node.

strata graph add-node

Adds a node to a graph or replaces it if the node id already exists. A node carries optional JSON properties, an optional declared object type (validated once the graph's ontology is frozen), and an optional entity binding that links the node to a row in another primitive. Cross-branch bindings are rejected.

To see the complete help for this command, run:

strata graph add-node --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alice --type person --properties '{"age":30}'created node alice in socialstrata graph get-node social alicenode_id      alicegraph        socialobject_type  personproperties   {"age":30}version      …
View details →

node get

Read one graph node.

strata graph get-node

Reads one node by id, returning its properties, declared object type, entity binding, and last-write commit coordinates. A removed or never-written node reads back as no data. Accepts `as_of` for time travel.

To see the complete help for this command, run:

strata graph get-node --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alice --type person --properties '{"age":30}'created node alice in socialstrata graph get-node social alicenode_id      alicegraph        socialobject_type  personproperties   {"age":30}version      …strata graph get-node social absent(nil)
View details →

node list

List graph nodes.

strata graph list-nodes

Lists a graph's nodes in node-id order. Accepts an optional id prefix filter, an item limit (default 100), an exclusive cursor, and `as_of` for time travel. Each item carries the full node payload: properties, declared type, binding, and commit coordinates.

To see the complete help for this command, run:

strata graph list-nodes --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph add-node social bobcreated node bob in socialstrata graph list-nodes socialNODE_ID  OBJECT_TYPE  VERSIONalice    -                  …bob      -                  …
View details →

node remove

Remove a graph node and its edges.

strata graph remove-node

Removes a node and every edge incident to it in one commit. Removing a node that does not exist is not an error: the acknowledgement reports `deleted: false`.

To see the complete help for this command, run:

strata graph remove-node --help

Example

strata graph create socialcreated graph socialstrata graph add-node social alicecreated node alice in socialstrata graph remove-node social alicedeleted node alice in socialstrata graph get-node social alice(nil)
View details →

Ontology

ontology define_object_type

Define a graph object type.

strata graph ontology define-object-type

Declares an object type in the graph's ontology: a name plus property definitions (`value_type`, `required`). While the ontology is a draft, redefining a type replaces it freely. After `graph.ontology.freeze`, the ontology is immutable and this command fails with `failed_precondition.engine.graph_ontology_frozen`.

To see the complete help for this command, run:

strata graph ontology define-object-type --help

Example

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology summary ggraph         gstatus        draftversion       …object_types  NAME    NODE_COUNT  PROPERTIES  person           0  -link_types    -
View details →

ontology delete_object_type

Delete a draft object type.

strata graph ontology delete-object-type

Removes an object type from the graph's draft ontology. Deleting a type that was never declared is not an error: the acknowledgement reports `deleted: false`. Once the ontology is frozen this command fails with `failed_precondition.engine.graph_ontology_frozen`.

To see the complete help for this command, run:

strata graph ontology delete-object-type --help

Example

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology define-object-type g companycreated object type company in gstrata graph ontology delete-object-type g companydeleted object type company in gstrata graph ontology summary ggraph         gstatus        draftversion       …object_types  NAME    NODE_COUNT  PROPERTIES  person           0  -link_types    -
View details →

ontology freeze

Freeze the graph ontology.

strata graph ontology freeze

Validates the draft ontology and freezes it. Validation requires at least one declared type and rejects link types whose source or target reference undeclared object types (`failed_precondition.engine.graph_ontology_freeze`). After freezing, writes enforce declared node object types, required properties, and link-type endpoint rules; the ontology itself can no longer change (`failed_precondition.engine.graph_ontology_frozen`).

To see the complete help for this command, run:

strata graph ontology freeze --help

Example

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology freeze gfroze ontology of g (1 object type, 0 link types)strata graph ontology get ggraph         gstatus        frozenversion       …object_types  NAME    PROPERTIES  person  -link_types    -
View details →

ontology get

Read the graph ontology.

strata graph ontology get

Reads the graph's ontology: its status (`draft` or `frozen`) plus every declared object type and link type with their property definitions. Returns no data before any type has been declared. Accepts `as_of` for time travel.

To see the complete help for this command, run:

strata graph ontology get --help

Example

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology get ggraph         gstatus        draftversion       …object_types  NAME    PROPERTIES  person  -link_types    -
View details →

ontology summary

Read the ontology with usage counts.

strata graph ontology summary

Reads the graph's ontology annotated with per-type usage: a node count for each object type and an edge count for each link type. Returns no data before any type has been declared. Accepts `as_of` for time travel.

To see the complete help for this command, run:

strata graph ontology summary --help

Example

strata graph create gcreated graph gstrata graph ontology define-object-type g personcreated object type person in gstrata graph ontology summary ggraph         gstatus        draftversion       …object_types  NAME    NODE_COUNT  PROPERTIES  person           0  -link_types    -
View details →