graph

edge.add

Add or replace a graph edge.

strata graph add-edge

wire 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.

Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.

To see the complete help for this command, run:

strata graph add-edge --help

Example

Add a typed edge between two nodes.

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     …

Parameters

NameTypeRequiredDescription
dststringyesDestination node id.
edge_typestringyesEdge type.
graphstringyesGraph name.
srcstringyesSource node id.
branchstring or nullnoTarget branch. Defaults to the executor handle branch.
propertiesanynoOptional edge properties.
spacestring or nullnoTarget product space. Defaults to `"default"`.
weightnumber or nullnoOptional edge weight. Defaults to 1.0. A finite number; a whole number up to 2^53 − 1 (9007199254740991) is stored exactly, and shortest-path distances summed from such weights stay exact up to the same bound, so a graph weighted in meters or seconds needs no parallel property.

Returns

MutationAck

  • dataobject
  • typestring

Errors

Recover by code. Retry policy and commit outcome come from the shipped error registry.

← All 31 Graph commands

agents: this page as markdown → /docs/reference/graph/edge/add.md