Skip to main content

Home > @jsplumbtoolkit/core > Graph > findPath

Graph.findPath() method

Finds the shortest path from source to target, using the Djikstra algorithm.

Signature:

findPath(source: string | Vertex, target: string | Vertex, strict?: boolean, nodeFilter?: Function, edgeFilter?: Function): ShortestPathResult;

Parameters

ParameterTypeDescription
sourcestring | VertexSource Node or Node ID.
targetstring | VertexTarget Node or Node ID.
strictbooleanDefaults 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.
nodeFilterFunctionOptional function that is given each Node's backing data and asked to return true or false - true means include the Node, false means exclude it.
edgeFilterFunctionOptional function that is given each Edge's backing data and asked to return true or false - true means include the Edge, false means exclude it.

Returns:

ShortestPathResult

A ShortestPathResult object.