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[] |