| 140 | |
| 141 | /** 获取回溯路径 - Flow */ |
| 142 | export function getFlowRecallEdges(graph: G6.Graph, node: G6.Node, targetIds: string[] = [], edges: G6.Edge[] = []) { |
| 143 | const inEdges: G6.Edge[] = node.getInEdges(); |
| 144 | |
| 145 | if (!inEdges.length) { |
| 146 | return []; |
| 147 | } |
| 148 | |
| 149 | inEdges.map(edge => { |
| 150 | const sourceId = edge.getModel().source; |
| 151 | const sourceNode = graph.findById(sourceId); |
| 152 | |
| 153 | edges.push(edge); |
| 154 | |
| 155 | const targetId = node.get('id'); |
| 156 | |
| 157 | targetIds.push(targetId); |
| 158 | |
| 159 | if (!targetIds.includes(sourceId)) { |
| 160 | getFlowRecallEdges(graph, sourceNode, targetIds, edges); |
| 161 | } |
| 162 | }); |
| 163 | |
| 164 | return edges; |
| 165 | } |
| 166 | |
| 167 | /** 获取回溯路径 - Mind */ |
| 168 | export function getMindRecallEdges(graph: G6.TreeGraph, node: G6.Node, edges: G6.Edge[] = []) { |