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 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"}'strata graph meta g
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 socialstrata graph list
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 tempstrata graph delete tempstrata graph list
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 socialstrata graph list
View details →

meta

Read graph metadata and counts.

strata graph meta

Reads a graph's metadata: live node and edge counts plus the create and last-update commit versions and timestamps. Reading a graph that does not exist returns no data rather than an error. Accepts `as_of` for time travel.

To see the complete help for this command, run:

strata graph meta --help

Example

strata graph create socialstrata graph add-node social alicestrata graph add-node social bobstrata graph meta social
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 socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph neighbors social alice --direction outgoing
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 gstrata graph add-node g a --type personstrata graph add-node g b --type personstrata graph nodes-by-type g 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 gstrata graph add-node g astrata graph add-node g bstrata graph sample g
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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph bfs g a
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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph cdlp g
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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph lcc g
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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph pagerank g
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. Edge weights (default 1.0) accumulate along paths; unreachable nodes are omitted from the result. Direction defaults to `outgoing`. 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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph sssp g a
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 gstrata graph add-node g astrata graph add-node g bstrata graph add-node g cstrata graph add-edge g a knows bstrata graph add-edge g b knows cstrata graph wcc g
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 socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph get-edge social alice knows bob
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 socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph get-edge social alice knows bobstrata graph get-edge social alice knows absent
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 socialstrata graph add-node social alicestrata graph add-node social bobstrata graph add-edge social alice knows bobstrata graph remove-edge social alice knows bobstrata graph get-edge social alice knows bob
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 socialstrata graph add-node social alice --type person --properties {"age":30}strata graph get-node social alice
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 socialstrata graph add-node social alice --type person --properties {"age":30}strata graph get-node social alicestrata graph get-node social absent
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 socialstrata graph add-node social alicestrata graph add-node social bobstrata graph list-nodes social
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 socialstrata graph add-node social alicestrata graph remove-node social alicestrata graph get-node social alice
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 gstrata graph ontology define-object-type g personstrata graph ontology summary g
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 gstrata graph ontology define-object-type g personstrata graph ontology define-object-type g companystrata graph ontology delete-object-type g companystrata graph ontology summary g
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 gstrata graph ontology define-object-type g personstrata graph ontology freeze gstrata graph ontology get g
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 gstrata graph ontology define-object-type g personstrata graph ontology get g
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 gstrata graph ontology define-object-type g personstrata graph ontology summary g
View details →