采样#
均匀随机游走#
-
cugraph_error_code_t cugraph_uniform_random_walks(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *start_vertices, size_t max_length, cugraph_random_walk_result_t **result, cugraph_error_t **error)#
计算均匀随机游走。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改。
start_vertices – [in] 源顶点数组
max_length – [in] 生成路径的最大长度
result – [out] 从node2vec调用中输出的结果
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
有偏随机游走#
-
cugraph_error_code_t cugraph_biased_random_walks(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *start_vertices, size_t max_length, cugraph_random_walk_result_t **result, cugraph_error_t **error)#
计算有偏随机游走。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改
start_vertices – [in] 源顶点数组
max_length – [in] 生成路径的最大长度
result – [out] 从node2vec调用中输出的结果
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
通过Node2Vec进行随机游走#
-
cugraph_error_code_t cugraph_node2vec_random_walks(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *start_vertices, size_t max_length, double p, double q, cugraph_random_walk_result_t **result, cugraph_error_t **error)#
使用node2vec框架计算随机游走。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改。
start_vertices – [in] 源顶点数组
max_length – [in] 生成路径的最大长度
compress_result – [in] 如果为true,返回路径为压缩稀疏行矩阵,否则返回为密集矩阵
p – [in] 返回参数
q – [in] 输入/输出参数
result – [out] 从node2vec调用中输出的结果
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
Node2Vec#
-
cugraph_error_code_t cugraph_node2vec(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *sources, size_t max_depth, bool_t compress_result, double p, double q, cugraph_random_walk_result_t **result, cugraph_error_t **error)#
使用node2vec框架计算随机游走。
- Deprecated:
此调用应替换为 cugraph_node2vec_random_walks
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改
sources – [in] 源顶点数组
max_depth – [in] 生成路径的最大长度
compress_result – [in] 如果为true,返回路径为压缩稀疏行矩阵,否则返回为密集矩阵
p – [in] 返回参数
q – [in] 输入/输出参数
result – [out] 从node2vec调用中输出的结果
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
均匀邻居采样#
-
cugraph_error_code_t cugraph_uniform_neighbor_sample(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *start_vertices, const cugraph_type_erased_device_array_view_t *start_vertex_labels, const cugraph_type_erased_device_array_view_t *label_list, const cugraph_type_erased_device_array_view_t *label_to_comm_rank, const cugraph_type_erased_device_array_view_t *label_offsets, const cugraph_type_erased_host_array_view_t *fan_out, cugraph_rng_state_t *rng_state, const cugraph_sampling_options_t *options, bool_t do_expensive_check, cugraph_sample_result_t **result, cugraph_error_t **error)#
均匀邻域采样。
- Deprecated:
此API将被删除,请使用cugraph_homogeneous_uniform_neighbor_sample
返回指定起始顶点周围的邻域样本。可选地,每个起始顶点可以与一个标签关联,允许调用者在同一函数调用中指定多批采样请求——这应该会提高GPU的利用率。
如果标签为NULL,则所有起始顶点将被视为同一批次的一部分,并且返回值将不包含标签列。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针。注意:如果存储需要转置,图可能会被修改
start_vertices – [in] 采样的起始顶点设备数组
start_vertex_labels – [in] 用于采样的起始顶点标签的设备数组。与每个起始顶点相关联的标签将包含在从该起始顶点派生的结果的输出中。我们仅支持INT32类型的标签。如果标签为NULL,返回的数据将不会被标记。
label_list – [in] 包含在
start_vertex_labels中的标签的设备数组。如果未指定label_to_comm_rank,则忽略此参数。如果指定,label_list必须按升序排序。label_to_comm_rank – [in] 设备数组,用于标识特定标签的输出应在输出中混洗到哪个通信等级。如果未指定,则数据在输出中不会组织。如果指定,则来自
label_list[i]的所有数据将混洗到等级。除非同时指定了start_vertex_labelslabel_to_comm_rank[i],否则不能指定此参数。如果未指定,则输出数据不会在等级之间混洗。label_offsets – [in] 设备数组中每个标签在种子列表中的偏移量。此参数仅在启用retain_seeds选项时使用。
fan_out – [in] 主机数组,定义采样算法中每一步的扇出。我们仅支持类型为 INT32 的 fan_out 值。
rng_state – [inout] 随机数生成器的状态,每次调用时更新
sampling_options – [in] 定义采样选项的不透明指针。
do_expensive_check – [in] 一个标志,用于运行输入参数的昂贵检查(如果设置为true)
result – [out] 来自 uniform_neighbor_sample 调用的输出
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
采样支持函数#
-
cugraph_type_erased_device_array_view_t *cugraph_lookup_result_get_srcs(const cugraph_lookup_result_t *result)#
从查找结果中获取边缘源。
- Parameters:
result – [in] 使用边ID和类型从src-dst查找的结果
- Returns:
类型擦除数组指向边的源
-
cugraph_type_erased_device_array_view_t *cugraph_lookup_result_get_dsts(const cugraph_lookup_result_t *result)#
从查找结果中获取边缘目的地。
- Parameters:
result – [in] 使用边ID和类型进行源-目标查找的结果
- Returns:
类型擦除数组指向边的目的地
-
void cugraph_lookup_result_free(cugraph_lookup_result_t *result)#
释放一个源-目的查找结果。
- Parameters:
result – [in] 使用边ID和类型进行源-目标查找的结果
-
void cugraph_lookup_container_free(cugraph_lookup_container_t *container)#
释放一个采样查找映射。
- Parameters:
container – [in] 采样查找映射(也称为容器)。
-
size_t cugraph_random_walk_result_get_max_path_length(cugraph_random_walk_result_t *result)#
从随机游走结果中获取最大路径长度。
- Parameters:
result – [in] 随机游走的结果
- Returns:
最大路径长度
-
cugraph_type_erased_device_array_view_t *cugraph_random_walk_result_get_paths(cugraph_random_walk_result_t *result)#
获取路径中顶点的矩阵(行主序)。
- Parameters:
result – [in] 随机游走算法的结果
- Returns:
类型擦除的数组,指向设备内存中的路径矩阵
-
cugraph_type_erased_device_array_view_t *cugraph_random_walk_result_get_weights(cugraph_random_walk_result_t *result)#
获取路径中边权重的矩阵(行主序)。
- Parameters:
result – [in] 随机游走算法的结果
- Returns:
类型擦除数组指向设备内存中的路径边权重
-
cugraph_type_erased_device_array_view_t *cugraph_random_walk_result_get_path_sizes(cugraph_random_walk_result_t *result)#
如果随机游走结果被压缩,获取路径大小。
- Deprecated:
一旦调用了新的node2vec,此调用将不再相关
- Parameters:
result – [in] 随机游走算法的结果
- Returns:
类型擦除数组指向设备内存中的路径大小
-
void cugraph_random_walk_result_free(cugraph_random_walk_result_t *result)#
自由随机游走结果。
- Parameters:
result – [in] 随机游走的结果
-
cugraph_error_code_t cugraph_sampling_options_create(cugraph_sampling_options_t **options, cugraph_error_t **error)#
创建采样选项对象。
所有采样选项设置为FALSE
- Parameters:
options – [out] 指向采样选项的不透明指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
-
void cugraph_sampling_set_retain_seeds(cugraph_sampling_options_t *options, bool_t value)#
设置标志以保留种子(原始来源)
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_set_renumber_results(cugraph_sampling_options_t *options, bool_t value)#
设置标志以重新编号结果。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_set_compress_per_hop(cugraph_sampling_options_t *options, bool_t value)#
设置是否按跳压缩(True)或全局压缩(False)
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_set_with_replacement(cugraph_sampling_options_t *options, bool_t value)#
设置标志以进行有放回抽样。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_set_return_hops(cugraph_sampling_options_t *options, bool_t value)#
设置标志以采样返回跳数。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_set_compression_type(cugraph_sampling_options_t *options, cugraph_compression_type_t value)#
设置压缩类型。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 定义压缩类型的枚举
-
void cugraph_sampling_set_prior_sources_behavior(cugraph_sampling_options_t *options, cugraph_prior_sources_behavior_t value)#
设置先前的来源行为。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 定义先前来源行为的枚举
-
void cugraph_sampling_set_dedupe_sources(cugraph_sampling_options_t *options, bool_t value)#
在采样前设置标志以对dedupe_sources进行采样去重。
- Parameters:
options – - 指向采样选项的不透明指针
value – - 要分配给选项的布尔值
-
void cugraph_sampling_options_free(cugraph_sampling_options_t *options)#
免费采样选项对象。
- Parameters:
options – [in] 指向采样对象的不透明指针
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_majors(const cugraph_sample_result_t *result)#
从采样算法结果中获取主要顶点。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向设备内存中的主要顶点
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_minors(const cugraph_sample_result_t *result)#
从采样算法结果中获取次要顶点。
- Parameters:
result – [in] 采样算法的结果
- Returns:
指向设备内存中次要顶点的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_major_offsets(const cugraph_sample_result_t *result)#
从采样算法结果中获取主要偏移量。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向设备内存中的主要偏移量
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_start_labels(const cugraph_sample_result_t *result)#
从采样算法结果中获取起始标签。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向起始标签
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_edge_id(const cugraph_sample_result_t *result)#
从采样算法结果中获取edge_id。
- Parameters:
result – [in] 采样算法的结果
- Returns:
指向 edge_id 的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_edge_type(const cugraph_sample_result_t *result)#
从采样算法结果中获取edge_type。
- Parameters:
result – [in] 采样算法的结果
- Returns:
指向 edge_type 的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_edge_weight(const cugraph_sample_result_t *result)#
从采样算法结果中获取 edge_weight。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向 edge_weight
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_hop(const cugraph_sample_result_t *result)#
从采样算法结果中获取跳数。
- Parameters:
result – [in] 采样算法的结果
- Returns:
指向跳转的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_label_hop_offsets(const cugraph_sample_result_t *result)#
从采样算法结果中获取标签跳转偏移量。
- Parameters:
result – [in] 采样算法的结果
- Returns:
指向标签跳转偏移量的类型擦除数组
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_label_type_hop_offsets(const cugraph_sample_result_t *result)#
从采样算法结果中获取标签类型跳转偏移量。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向标签类型跳转偏移量
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_index(const cugraph_sample_result_t *result)#
从采样算法结果中获取索引。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向索引
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_renumber_map(const cugraph_sample_result_t *result)#
获取重新编号的映射。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向重新编号映射
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_renumber_map_offsets(const cugraph_sample_result_t *result)#
获取重新编号的映射偏移量。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向重新编号映射的偏移量
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_edge_renumber_map(const cugraph_sample_result_t *result)#
获取边的重新编号映射。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向重新编号映射
-
cugraph_type_erased_device_array_view_t *cugraph_sample_result_get_edge_renumber_map_offsets(const cugraph_sample_result_t *result)#
获取边缘重新编号的映射偏移量。
- Parameters:
result – [in] 采样算法的结果
- Returns:
类型擦除数组指向重新编号映射
-
void cugraph_sample_result_free(cugraph_sample_result_t *result)#
释放一个采样结果。
- Parameters:
result – [in] 采样算法的结果
-
cugraph_error_code_t cugraph_test_sample_result_create(const cugraph_resource_handle_t *handle, const cugraph_type_erased_device_array_view_t *srcs, const cugraph_type_erased_device_array_view_t *dsts, const cugraph_type_erased_device_array_view_t *edge_id, const cugraph_type_erased_device_array_view_t *edge_type, const cugraph_type_erased_device_array_view_t *wgt, const cugraph_type_erased_device_array_view_t *hop, const cugraph_type_erased_device_array_view_t *label, cugraph_sample_result_t **result, cugraph_error_t **error)#
创建一个抽样结果(测试API)
- Parameters:
handle – [in] 用于访问资源的句柄
srcs – [in] 用于填充srcs的设备数组视图
dsts – [in] 用于填充目标数组的设备数组视图
edge_id – [in] 用于填充 edge_id 的设备数组视图(可以为 NULL)
edge_type – [in] 用于填充 edge_type 的设备数组视图(可以为 NULL)
wgt – [in] 用于填充 wgt 的设备数组视图(可以为 NULL)
hop – [in] 设备数组视图以填充 hop
label – [in] 用于填充标签的设备数组视图(可以为 NULL)
result – [out] 指向存储 cugraph_sample_result_t* 的位置的指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
-
cugraph_error_code_t cugraph_test_uniform_neighborhood_sample_result_create(const cugraph_resource_handle_t *handle, const cugraph_type_erased_device_array_view_t *srcs, const cugraph_type_erased_device_array_view_t *dsts, const cugraph_type_erased_device_array_view_t *edge_id, const cugraph_type_erased_device_array_view_t *edge_type, const cugraph_type_erased_device_array_view_t *weight, const cugraph_type_erased_device_array_view_t *hop, const cugraph_type_erased_device_array_view_t *label, cugraph_sample_result_t **result, cugraph_error_t **error)#
创建一个抽样结果(测试API)
- Parameters:
handle – [in] 用于访问资源的句柄
srcs – [in] 用于填充srcs的设备数组视图
dsts – [in] 用于填充目标数组的设备数组视图
edge_id – [in] 用于填充edge_id的设备数组视图
edge_type – [in] 用于填充edge_type的设备数组视图
weight – [in] 设备数组视图用于填充权重
hop – [in] 设备数组视图以填充 hop
label – [in] 用于填充标签的设备数组视图
result – [out] 指向存储 cugraph_sample_result_t* 的位置的指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
-
cugraph_error_code_t cugraph_select_random_vertices(const cugraph_resource_handle_t *handle, const cugraph_graph_t *graph, cugraph_rng_state_t *rng_state, size_t num_vertices, cugraph_type_erased_device_array_t **vertices, cugraph_error_t **error)#
从图中随机选择顶点。
- Parameters:
handle – [in] 用于访问资源的句柄
graph – [in] 指向图的指针
rng_state – [inout] 随机数生成器的状态,每次调用时更新
num_vertices – [in] 要采样的顶点数量
vertices – [out] 设备数组视图,用于填充标签
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码
-
cugraph_error_code_t cugraph_negative_sampling(const cugraph_resource_handle_t *handle, cugraph_rng_state_t *rng_state, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *vertices, const cugraph_type_erased_device_array_view_t *src_biases, const cugraph_type_erased_device_array_view_t *dst_biases, size_t num_samples, bool_t remove_duplicates, bool_t remove_existing_edges, bool_t exact_number_of_samples, bool_t do_expensive_check, cugraph_coo_t **result, cugraph_error_t **error)#
执行负采样。
负采样根据指定的参数生成定义边的COO结构
- Parameters:
handle – [in] 用于访问资源的句柄
rng_state – [inout] 随机数生成器的状态,每次调用时更新
graph – [in] 指向图的指针
vertices – [in] 源偏置的顶点ID。如果未指定
src_bias和dst_bias,则忽略此参数。如果指定了vertices,则vertices[i]是src_biases[i]和dst_biases[i]的顶点ID。如果未指定vertices,则i是src_biases[i]和dst_biases[i]的顶点ID。src_biases – [in] 用于选择源顶点的偏差。如果为NULL,则进行均匀采样;如果提供了偏差,顶点i的概率将为src_bias[i] / (所有源偏差的总和)
dst_biases – [in] 用于选择目标顶点的偏差。如果为NULL,则进行均匀采样;如果提供了偏差,顶点i的概率将为dst_bias[i] / (所有目标偏差的总和)
num_samples – [in] 要生成的负样本数量
remove_duplicates – [in] 如果为true,从采样的边中移除重复项
remove_existing_edges – [in] 如果为true,则移除图中实际存在的采样边
exact_number_of_samples – [in] 如果为 true,结果应精确包含
num_samples。如果为 false,代码将生成num_samples,然后根据指定的条件进行过滤。do_expensive_check – [in] 一个标志,用于运行输入参数的昂贵检查(如果设置为true)
result – [out] 指向生成的coo列表的不透明指针
error – [out] 指向存储任何错误详细信息的错误对象的指针。如果错误代码不是CUGRAPH_SUCCESS,将会被填充。
- Returns:
错误代码