Skip to main content

Home > @jsplumbtoolkit/core > Graph > getDistance

Graph.getDistance() method

Finds the distance between source and target.

Signature:

getDistance(source: Vertex, target: Vertex, strict?: boolean): number;

Parameters

ParameterTypeDescription
sourceVertexSource vertex or vertex ID.
targetVertexTarget vertex or vertex ID.
strictbooleanDefauls to true. Sets whether or not paths are searched strictly by the given source/target. If, for instance, you supply a node as the source, but there are only edges connected to ports on that node, by default these edges will be ignored. Switching strict to false will mean these edges are considered.

Returns:

number

Distance from the source to the target.