edge.*

2 min read

Edge inherits from item. The functions of Item are also available for Edge. This document will only introduce the common functions for Edge class. All the built-in edges can be found in Built-in Edges Doc and demo, Custom Edge can be found in Custom Edge Doc and demo.

edge.setSource(source)

Set the source item (node) of the edge.

Parameters

NameTypeRequiredDescription
sourceNodetrueThe item of source node.

Usage

const edge = new Edge({
  // ...
});

const node = new Node({
  // ...
});

edge.setSource(node);

edge.setTarget(target)

Set the target item (node) of the edge.

Parameters

NameTypeRequiredDescription
targetNodetrueThe item of target node.

Usage

edge.setTarget(node);

edge.getSource()

Get the current source item (node) of the edge.

Return

  • The type of return value: Node;
  • Returns the item of source node.

Usage

const node = edge.getSource();

edge.getTarget()

Get the current target item (node) of the edge.

Return

  • The type of return value: Node;
  • Returns the item of target node.

Usage

const node = edge.getTarget();