文档首页> 图引擎服务 GES> 开发指南> 使用业务面SDK> 执行算法> Filtered All Pairs Shortest paths算法
更新时间:2022-06-30 GMT+08:00

Filtered All Pairs Shortest paths算法

您可以使用GES提供的接口执行Filtered All Pairs Shortest paths算法。示例代码如下:

public void filteredAllPairsShortestPaths(GraphClient graphClient) throws ApiException {
    FilteredAllPairsShortestPathsParameters filteredAllPairsShortestPathsParameters = new FilteredAllPairsShortestPathsParameters();
    filteredAllPairsShortestPathsParameters.setSources("Vivian");
    filteredAllPairsShortestPathsParameters.setTargets("Lethal Weapon");
 
    AlgorithmReq algorithmReq = new AlgorithmReq();
    algorithmReq.setAlgorithmName(AlgorithmNames.FILTERED_ALL_PAIRS_SHORTEST_PATHS);  // 算法名
    algorithmReq.setParameters(filteredAllPairsShortestPathsParameters);  // 算法参数
 
    // 根据输入参数执行指定算法
    AsyncAPIResp asyncAPIResp = graphClient.algorithmQuery(algorithmReq);
 
    // 根据算法执行任务id,查询任务执行状态
    QueryJobReq queryJobReq = new QueryJobReq();
    queryJobReq.setJobId(asyncAPIResp.getJobId());
    GesResponse gesResponse =  graphClient.queryAsyncTask(queryJobReq);
    System.out.println(gesResponse);
}