广度优先搜索 (BFS)#

cugraph_error_code_t cugraph_bfs(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, cugraph_type_erased_device_array_view_t *sources, bool_t direction_optimizing, size_t depth_limit, bool_t compute_predecessors, bool_t do_expensive_check, cugraph_paths_result_t **result, cugraph_error_t **error)#

从一组种子顶点执行广度优先搜索。

此函数计算从源顶点到各顶点的距离(到达顶点的最小跳数)。如果 predecessors 不为 NULL,此函数还会计算每个顶点的前驱(广度优先搜索树中的父顶点)。

参数:

handle[in] 访问资源的句柄
  • graph[in] 指向图的指针 FIXME: 只做 [in],如果需要临时修改内部,则复制

  • sources[inout] 源顶点数组。注意:如果为图启用了重新编号,数组可能会被修改

  • direction_optimizing[in] 如果设置为 true,此算法会根据广度优先搜索前沿的大小在基于推的广度优先搜索和基于拉的广度优先搜索之间切换(当前不支持)。此选项仅对对称输入图有效。

  • depth_limit – 设置广度优先搜索的最大迭代次数。任何距离 source_vertex 跳数超过 depth_limit 的顶点将被标记为不可达。

  • compute_predecessors[in] 指示是否在结果中计算前驱的标志

  • do_expensive_check[in] 运行输入参数昂贵检查的标志(如果设置为 true)。

  • result[out] 指向路径结果的不透明指针

  • error[out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是 CUGRAPH_SUCCESS,则会填充此对象

  • 返回:

错误代码

单源最短路径 (SSSP)#

cugraph_error_code_t cugraph_sssp(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t source, double cutoff, bool_t compute_predecessors, bool_t do_expensive_check, cugraph_paths_result_t **result, cugraph_error_t **error)#

执行单源最短路径计算从源顶点到各顶点的最小距离(和前驱)。

此函数计算从源顶点到各顶点的距离(最小边权重之和)。如果 predecessors 不为 NULL,此函数还会计算每个顶点的前驱(广度优先搜索树中的父顶点)。

graph[in] 指向图的指针

handle[in] 访问资源的句柄
  • graph[in] 指向图的指针 FIXME: 只做 [in],如果需要临时修改内部,则复制

  • source[in] 源顶点 ID

  • cutoff[in] 要考虑的最大边权重之和

  • 路径提取#

  • do_expensive_check[in] 运行输入参数昂贵检查的标志(如果设置为 true)。

  • result[out] 指向路径结果的不透明指针

  • error[out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是 CUGRAPH_SUCCESS,则会填充此对象

  • 返回:

错误代码

单源最短路径 (SSSP)#

cugraph_error_code_t cugraph_extract_paths(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *sources, const cugraph_paths_result_t *paths_result, const cugraph_type_erased_device_array_view_t *destinations, cugraph_extract_paths_result_t **result, cugraph_error_t **error)#

从 cugraph_paths_result_t 中提取 BFS 或 SSSP 路径。

此函数从 BFS 或 SSSP 输出中提取路径。BFS 和 SSSP 输出距离和前驱。从顶点 v 回溯到原始源顶点的路径可以通过递归查找前驱顶点直到回到原始源顶点来提取。

graph[in] 指向图的指针。注意:如果需要转置存储,图可能会被修改

handle[in] 访问资源的句柄
  • graph[in] 指向图的指针 FIXME: 只做 [in],如果需要临时修改内部,则复制

  • sources[in] 源顶点数组

  • result[in] BFS 调用的输出

  • destinations[in] 目标顶点数组。

  • result[out] 指向 extract_paths 结果的不透明指针

  • 提取最大路径长度#

  • 返回:

错误代码

单源最短路径 (SSSP)#

size_t cugraph_extract_paths_result_get_max_path_length(cugraph_extract_paths_result_t *result)#

从 extract_paths 结果中获取最大路径长度。

result[in] extract_paths 的结果

handle[in] 访问资源的句柄

最大路径长度

错误代码

遍历支持函数#

cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_vertices(cugraph_paths_result_t *result)#

从路径结果中获取顶点 ID。

result[in] bfs 或 sssp 的结果

handle[in] 访问资源的句柄

类型擦除的顶点 ID 数组

错误代码

cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_distances(cugraph_paths_result_t *result)#

从路径结果中获取距离。

类型擦除的距离数组

handle[in] 访问资源的句柄

类型擦除的顶点 ID 数组

错误代码

cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_predecessors(cugraph_paths_result_t *result)#

从路径结果中获取前驱。

类型擦除的前驱数组。如果在生成此结果的 bfs 或 sssp 调用中 compute_predecessors 为 FALSE,则值为 NULL。

handle[in] 访问资源的句柄

类型擦除的顶点 ID 数组

错误代码

void cugraph_paths_result_free(cugraph_paths_result_t *result)#

释放路径结果。

cugraph_type_erased_device_array_view_t *cugraph_extract_paths_result_get_paths(cugraph_extract_paths_result_t *result)#

handle[in] 访问资源的句柄

类型擦除的顶点 ID 数组

获取路径矩阵(行主序)。

指向设备内存中矩阵的类型擦除数组

handle[in] 访问资源的句柄

最大路径长度

错误代码

void cugraph_extract_paths_result_free(cugraph_extract_paths_result_t *result)#

释放 extract_paths 结果。

下一页

cuGraph C++ API

handle[in] 访问资源的句柄

最大路径长度

本页内容