getConnectedEdges()
此工具會篩選給定的邊緣陣列,僅保留來源或目標節點在給定節點陣列中的邊緣。
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' }]
簽名
名稱 | 類型 |
---|---|
#參數 |
|
# nodes | Node[] |
# edges | Edge[] |
#回傳值 |
|
Edge[] |