更新时间:2022-06-30 GMT+08:00

n_paths算法

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

public void nPaths(GraphClient graphClient) throws ApiException {
    NPathsParameters nPathsParameters = new NPathsParameters();
    nPathsParameters.setSource("Vivian");
    nPathsParameters.setTarget("Katherine");
    nPathsParameters.setDirected(false);
    nPathsParameters.setN(10);
    nPathsParameters.setK(5);
 
    AlgorithmReq algorithmReq = new AlgorithmReq();
    algorithmReq.setAlgorithmName(AlgorithmNames.N_PATHS);  // 算法名
    algorithmReq.setParameters(nPathsParameters);  // 算法参数
 
    // 根据输入参数执行指定算法
    AsyncAPIResp asyncAPIResp = graphClient.algorithmQuery(algorithmReq);
 
    // 根据算法执行任务id,查询任务执行状态
    QueryJobReq queryJobReq = new QueryJobReq();
    queryJobReq.setJobId(asyncAPIResp.getJobId());
    GesResponse gesResponse =  graphClient.queryAsyncTask(queryJobReq);
    System.out.println(gesResponse);
}