更新时间:2022-12-08 GMT+08:00

All_shortest_paths算法

您可以使用GES提供的接口执行all_shortest_paths算法。示例代码如下

public static void executeAlgorithm(GraphClient graphClient) throws ApiException
{
AllShortestPathParameters parameters = new AllShortestPathParameters();
 parameters.setSource("46");
 parameters.setTarget("35");
//算法请求
AlgorithmReq req = new AlgorithmReq();
//设置算法名称
req.setAlgorithmName(AlgorithmNames.ALL_SHORTEST_PATHS);
 req.setParameters(parameters);
//执行算法
AsyncAPIResp asyncAPIResp = graphClient.algorithmQuery(req);
//获取JobId
String jobId = asyncAPIResp.getJobId();
 AllShortestPathJobReq req1 = new AllShortestPathJobReq();
 req1.setJobId(jobId);
//根据JobId查询算法执行结果
 System.out.println(graphClient.queryJobStatus(req1));
}