遍历#
广度优先搜索 (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不为空,此函数还会计算每个顶点的前驱(广度优先搜索树中的父顶点)。- Parameters:
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,将会被填充。
- Returns:
错误代码
单源最短路径 (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不为空,此函数还会计算每个顶点的前驱(广度优先搜索树中的父顶点)。- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针
source – [in] 源顶点ID
cutoff – [in] 要考虑的最大边权重和
compute_predecessors – [in] 一个标志,用于指示是否在结果中计算前驱节点
do_expensive_check – [in] 一个标志,用于对输入参数运行昂贵的检查(如果设置为
true)。result – [out] 不透明的路径结果指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
路径提取#
-
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返回到原始源顶点的路径。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改
sources – [in] 源顶点数组
result – [in] BFS调用的输出结果
destinations – [in] 目标顶点数组。
result – [out] 指向 extract_paths 结果的不透明指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
提取最大路径长度#
-
size_t cugraph_extract_paths_result_get_max_path_length(cugraph_extract_paths_result_t *result)#
从extract_paths结果中获取最大路径长度。
- Parameters:
result – [in] 来自 extract_paths 的结果
- Returns:
最大路径长度
遍历支持函数#
-
cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_vertices(cugraph_paths_result_t *result)#
从路径结果中获取顶点ID。
- Parameters:
result – [in] bfs 或 sssp 的结果
- Returns:
顶点ID的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_distances(cugraph_paths_result_t *result)#
获取路径结果中的距离。
- Parameters:
result – [in] bfs 或 sssp 的结果
- Returns:
类型擦除的距离数组
-
cugraph_type_erased_device_array_view_t *cugraph_paths_result_get_predecessors(cugraph_paths_result_t *result)#
从路径结果中获取前驱节点。
- Parameters:
result – [in] bfs 或 sssp 的结果
- Returns:
类型擦除的前驱数组。如果在生成此结果的bfs或sssp调用中compute_predecessors为FALSE,则值为NULL。
-
void cugraph_paths_result_free(cugraph_paths_result_t *result)#
自由路径结果。
- Parameters:
result – [in] bfs 或 sssp 的结果
-
cugraph_type_erased_device_array_view_t *cugraph_extract_paths_result_get_paths(cugraph_extract_paths_result_t *result)#
获取路径的矩阵(行主序)。
- Parameters:
result – [in] 来自 extract_paths 的结果
- Returns:
指向设备内存中矩阵的类型擦除数组
-
void cugraph_extract_paths_result_free(cugraph_extract_paths_result_t *result)#
释放 extract_paths 的结果。
- Parameters:
result – [in] 来自 extract_paths 的结果