@graphty/graphty-element / extend / GraphSink
Interface: GraphSink ​
Defined in: graph-format/dist/src/types/builder.d.ts:125
The subset of GraphBuilder that importers may call (design section 8.3). Importers push scalars, never objects; the record methods exist for the transitional element path and JSON. GraphBuilder implements it, and tests can pass a recording sink.
Properties ​
directed ​
readonlydirected:boolean
Defined in: graph-format/dist/src/types/builder.d.ts:129
The current direction.
directedLocked ​
readonlydirectedLocked:boolean
Defined in: graph-format/dist/src/types/builder.d.ts:131
Whether lockDirected() was called.
edgeCount ​
readonlyedgeCount:number
Defined in: graph-format/dist/src/types/builder.d.ts:133
Live edge count.
options ​
readonlyoptions:ResolvedBuilderOptions
Defined in: graph-format/dist/src/types/builder.d.ts:127
The resolved options; directed is the current value.
Methods ​
addEdge() ​
addEdge(
source,target,weight?):number
Defined in: graph-format/dist/src/types/builder.d.ts:170
Add a logical edge; unknown endpoints are created when addMissingNodes is true, else E_UNKNOWN_NODE. NaN weight is E_INVALID_WEIGHT.
Parameters ​
source ​
NodeId
source node id
target ​
NodeId
target node id
weight? ​
number
the weight; 1 when omitted
Returns ​
number
the logical edge index
addEdgeRecord() ​
addEdgeRecord(
source,target,attrs,weightKey?):number
Defined in: graph-format/dist/src/types/builder.d.ts:300
Add an edge from a record; always creates a new edge (parallels are kept).
Parameters ​
source ​
NodeId
source node id
target ​
NodeId
target node id
attrs ​
Readonly<Record<string, unknown>>
attribute values keyed by column name
weightKey? ​
string | null
the key holding the weight; default "weight"; null = no weight
Returns ​
number
the logical edge index
addEdges() ​
addEdges(
src,dst,weights?):number
Defined in: graph-format/dist/src/types/builder.d.ts:178
Bulk add edges by node index (the index-space path used with addAnonymousNodes).
Parameters ​
src ​
source node indices
dst ​
target node indices
weights? ​
per-edge weights; 1 when omitted
Returns ​
number
the first new logical edge index
addExtensionRow() ​
addExtensionRow(
table,values):number
Defined in: graph-format/dist/src/types/builder.d.ts:283
Append a row to an extension table.
Parameters ​
table ​
ExtensionHandle
the table handle
values ​
readonly unknown[]
one value per declared column
Returns ​
number
the new row index
addExtensionTable() ​
addExtensionTable(
name,decls):ExtensionHandle
Defined in: graph-format/dist/src/types/builder.d.ts:276
Create an extension table (design section 5.10).
Parameters ​
name ​
string
the table name, e.g. "temporal:node:price"
decls ​
readonly ColumnDecl[]
its columns
Returns ​
ExtensionHandle
the table handle
addNode() ​
addNode(
id):number
Defined in: graph-format/dist/src/types/builder.d.ts:154
Add a node or return the index of an existing live one (idempotent); revives a tombstoned id before the next freeze.
Parameters ​
id ​
NodeId
the node id; E_INVALID_ID when not a legal id
Returns ​
number
the node index
addNodeRecord() ​
addNodeRecord(
id,attrs):number
Defined in: graph-format/dist/src/types/builder.d.ts:291
Add a node from a record; on an existing live id every key present overwrites that row (last-write-wins per attribute).
Parameters ​
id ​
NodeId
the node id
attrs ​
Readonly<Record<string, unknown>>
attribute values keyed by column name
Returns ​
number
the node index
addNodes() ​
addNodes(
ids,out?):U32
Defined in: graph-format/dist/src/types/builder.d.ts:161
Add many nodes.
Parameters ​
ids ​
Iterable<NodeId>
the node ids
out? ​
receives the index of every id (allocated when omitted)
Returns ​
out
declareEdgeColumn() ​
declareEdgeColumn(
decl):ColumnHandle
Defined in: graph-format/dist/src/types/builder.d.ts:216
Declare an edge column; the same declaration again returns the existing handle, a different one is E_COLUMN_EXISTS.
Parameters ​
decl ​
ColumnDecl
the declaration
Returns ​
ColumnHandle
the column handle
declareNodeColumn() ​
declareNodeColumn(
decl):ColumnHandle
Defined in: graph-format/dist/src/types/builder.d.ts:209
Declare a node column; the same declaration again returns the existing handle, a different one is E_COLUMN_EXISTS.
Parameters ​
decl ​
ColumnDecl
the declaration
Returns ​
ColumnHandle
the column handle
edgeColumn() ​
edgeColumn(
name):ColumnHandle
Defined in: graph-format/dist/src/types/builder.d.ts:228
Look up an edge column handle.
Parameters ​
name ​
string
the column name
Returns ​
ColumnHandle
the handle, or INVALID_INDEX when absent
edgeEndpoints() ​
edgeEndpoints(
edge): readonly [number,number]
Defined in: graph-format/dist/src/types/builder.d.ts:190
Read a live edge's endpoints back.
Parameters ​
edge ​
number
the logical edge index
Returns ​
readonly [number, number]
[source index, target index] in declared orientation
edgeWeight() ​
edgeWeight(
edge):number
Defined in: graph-format/dist/src/types/builder.d.ts:196
Read a live edge's weight back.
Parameters ​
edge ​
number
the logical edge index
Returns ​
number
the weight (1 when unweighted)
indexOf() ​
indexOf(
id):number
Defined in: graph-format/dist/src/types/builder.d.ts:202
Total lookup of a live node by id.
Parameters ​
id ​
NodeId
the node id
Returns ​
number
the node index, or INVALID_INDEX
nodeColumn() ​
nodeColumn(
name):ColumnHandle
Defined in: graph-format/dist/src/types/builder.d.ts:222
Look up a node column handle.
Parameters ​
name ​
string
the column name
Returns ​
ColumnHandle
the handle, or INVALID_INDEX when absent
reserve() ​
reserve(
nodes?,edges?):void
Defined in: graph-format/dist/src/types/builder.d.ts:147
Grow staging capacity ahead of a bulk push. E_TOO_LARGE for a node count past the 2^24 nodes with explicit ids one builder holds, or an edge count past MAX_COUNT.
Parameters ​
nodes? ​
number
expected node count
edges? ​
number
expected edge count
Returns ​
void
setDirected() ​
setDirected(
directed,options?):void
Defined in: graph-format/dist/src/types/builder.d.ts:140
Change the direction (design section 6.6): free while the builder holds no edges; with edges, only undirected -> directed with expand. E_DIRECTED when refused or locked.
Parameters ​
directed ​
boolean
the new value
options? ​
SetDirectedOptions
expansion of an undirected builder
Returns ​
void
setEdgeValue() ​
setEdgeValue(
column,edge,value):void
Defined in: graph-format/dist/src/types/builder.d.ts:257
Set one edge cell; a string column name auto-declares with inference.
Parameters ​
column ​
string | ColumnHandle
the handle or name
edge ​
number
the logical edge index
value ​
unknown
the value
Returns ​
void
setEdgeWeight() ​
setEdgeWeight(
edge,weight):void
Defined in: graph-format/dist/src/types/builder.d.ts:184
Set the weight of a live edge (allocates the weight array on first use).
Parameters ​
edge ​
number
the logical edge index
weight ​
number
the weight; E_INVALID_WEIGHT for NaN
Returns ​
void
setGraphValue() ​
setGraphValue(
name,value,decl?):void
Defined in: graph-format/dist/src/types/builder.d.ts:264
Set a graph-level attribute (the graph table's single row).
Parameters ​
name ​
string
the column name
value ​
unknown
the value
decl? ​
Loose<ColumnDecl>
declaration fields for a new column
Returns ​
void
setMeta() ​
setMeta(
meta):void
Defined in: graph-format/dist/src/types/builder.d.ts:269
Merge fields into the graph metadata; non-JSON extra values are E_COLUMN_TYPE.
Parameters ​
meta ​
GraphMetaPatch
the fields to set
Returns ​
void
setNodeValue() ​
setNodeValue(
column,index,value):void
Defined in: graph-format/dist/src/types/builder.d.ts:250
Set one node cell; a string column name auto-declares with inference (design section 5.1).
Parameters ​
column ​
string | ColumnHandle
the handle or name
index ​
number
the node index
value ​
unknown
the value
Returns ​
void
widenEdgeColumn()? ​
optionalwidenEdgeColumn(column,dtype):void
Defined in: graph-format/dist/src/types/builder.d.ts:243
Widen an inferred edge column; see widenNodeColumn().
Parameters ​
column ​
string | ColumnHandle
the handle or name
dtype ​
Dtype
the dtype to widen to
Returns ​
void
widenNodeColumn()? ​
optionalwidenNodeColumn(column,dtype):void
Defined in: graph-format/dist/src/types/builder.d.ts:237
Widen an inferred node column to a wider dtype of the design section 5.1 order without changing any value (a text importer that knows from the lexical grammar that 2.0 cells are f64 although every value so far was integral). Optional: a sink without it makes such an importer report the dtype it could not widen.
Parameters ​
column ​
string | ColumnHandle
the handle or name
dtype ​
Dtype
the dtype to widen to
Returns ​
void