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
| Key | Description |
|---|---|
sourceX, sourceY, targetX, targetY | Handle coordinates |
sourcePosition, targetPosition | Handle sides (Position enum) |
nodes | All graph nodes (from useNodes) |
options? | See Options |
Pipeline
nodes + endpoints → bounding boxes → grid → walkability → A* → SVG path
Related
createSmartEdge— preset wrappersmartEdgePresets— canonical preset configsgetSmartEdgeWaypoints— multi-segment routing through waypoints