Skip to main content

getSmartEdge

Central path computation API. Returns { svgPathString, edgeCenterX, edgeCenterY } on success, or an Error if no valid path was found.

import { getSmartEdge } from "@tisoap/react-flow-smart-edge";

const result = getSmartEdge({
sourcePosition,
targetPosition,
sourceX,
sourceY,
targetX,
targetY,
nodes,
options: {
nodePadding: 10,
gridRatio: 10,
},
});

if (result instanceof Error) {
// fall back to a default edge
} else {
const { svgPathString, edgeCenterX, edgeCenterY } = result;
}

Parameters

KeyDescription
sourceX, sourceY, targetX, targetYHandle coordinates
sourcePosition, targetPositionHandle sides (Position enum)
nodesAll graph nodes (from useNodes)
options?See Options

Pipeline

nodes + endpoints → bounding boxes → grid → walkability → A* → SVG path