getConnectedEdges()
Source on GitHub (opens in a new tab)
This util will filter a given an array of edges to keep only edges whether either the source or target node is in the given array of nodes.
import { getConnectedEdges } from '@xyflow/react';
const nodes = [
{ id: 'a', position: { x: 0, y: 0 } },
{ id: 'b', position: { x: 100, y: 0 } },
];
const edges = [
{ id: 'a->c', source: 'a', target: 'c' },
{ id: 'c->d', source: 'c', target: 'd' }
];
const connectedEdges = getConnectedEdges(nodes, edges);
// => [{ id: 'a->c', source: 'a', target: 'c' }]
Signature
Name | Type |
---|---|
#Params |
|
# nodes | Node[] |
# edges | Edge[] |
#Returns |
|
Edge[] |