Skip to content

defineEdgeAttribute

method

Back to Helios Network JS/WASM API

Kind
method
Source
src/js/HeliosNetwork.js:5700

Description

Defines an edge attribute backed by linear WASM memory.

Signature

defineEdgeAttribute(name, type, dimension = 1) {

Parameters

NameTypeAttributesDefaultDescription
namestringAttribute identifier.
typeAttributeTypeAttribute type constant.
dimensionnumberoptional1Number of elements per edge.

Returns

Type void

Example

const net = await HeliosNetwork.create();
net.addNodes(2);
net.defineEdgeAttribute('capacity', AttributeType.Integer);
const edges = net.addEdges([[0, 1]]);
net.withBufferAccess(() => {
  const capacity = net.getEdgeAttributeBuffer('capacity').view;
  capacity[edges[0]] = 10;
});