Skip to main content

Edges

Model object​

Edge

An edge connects two vertices.

Class Members​

NameTypeDescription
costnumberEdge cost
sourceVertexSource of the Edge.
targetVertexTarget of the Edge.
typestringObject's type.

Class Methods​

getCost​

Gets the cost for this edge. Defaults to 1.
Signature
getCost()
Return value
number

getFullId​

Alias for the getId method.
Signature
getFullId()
Return value
string

getId​

Gets the id for this Edge.
Signature
getId()
Return value
string

isDirected​

Gets whether or not the Edge is directed.
Signature
isDirected()
Return value
boolean

Internally, the model class represents an edge.

Data format​

On load and save, edges are represented by a EdgeData object with this definition:

EdgeData
The default type that represents an edge in a dataset to load or a saved dataset. Edges differ slightly from nodes and groups in that there are fields which are mandatory: source and data. Edges also differ from nodes and groups in that any backing data for an edge (including its id and/or type) need to be provided in the data member of the edge, not in the root as with nodes and groups.
NameTypeDescription
anchors?{
  source:ObjectAnchorSpec,
  target:ObjectAnchorSpec
}
Optional anchors for the edge.
cost?numberCost to associate with the edge. Defaults to 1. This value can be used when computing shortest paths.
data?ObjectDataOptional data to associate with the edge
directed?booleanWhether or not the given edge is directed, ie. when computing a path the edge can only be traversed from source to target. Defaults to false.
geometry?GeometryOptional geometry that defines the edge's path
sourcestring | PointXYEither the ID of the source vertex or a canvas location.
targetstring | PointXYEither the ID of the target vertex or a canvas location.

Adding Edges​

TBD

Removing Edges​

TBD