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
Parameter | Type | Description |
---|---|---|
source | string | Vertex | Source Node or Node ID. |
target | string | Vertex | Target Node or Node ID. |
strict | boolean | Defaults 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. |
nodeFilter | Function | Optional 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. |
edgeFilter | Function | Optional 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:
A ShortestPathResult object.