* @function GraphMap.prototype.findShortestPath * @version 11.2.0 * @description 获取开始节点和结束节点之间的最短路径。(在渲染完成后调用) * @param {GraphMap.findShortestPathParams} params - 参数。 * @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。 * @returns {Promise} Promise 对象。
(params, callback)
| 97 | * @returns {Promise} Promise 对象。 |
| 98 | */ |
| 99 | findShortestPath(params, callback) { |
| 100 | const { startID, endID, isHighlight = true, highlightStateStyles = {} } = params; |
| 101 | return this.knowledgeGraphService.findShortestPath({ startID, endID }, (res) => { |
| 102 | callback && callback(res); |
| 103 | if (isHighlight) { |
| 104 | if (res.type === 'processCompleted' && res.result.succeed) { |
| 105 | const { nodeIDs, edgeIDs } = res.result; |
| 106 | this.highlight({ nodeIDs, edgeIDs, ...highlightStateStyles }); |
| 107 | } else { |
| 108 | alert(res.error.errorMsg, false); |
| 109 | } |
| 110 | } |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @function GraphMap.prototype.highlight |