Centrality#

PageRank#

cugraph_error_code_t cugraph_pagerank(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_vertices, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_sums, const cugraph_type_erased_device_array_view_t *initial_guess_vertices, const cugraph_type_erased_device_array_view_t *initial_guess_values, double alpha, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute pagerank.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • precomputed_vertex_out_weight_vertices[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). This defines the vertices. Set to NULL if no value is passed.

  • precomputed_vertex_out_weight_sums[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). Set to NULL if no value is passed.

  • initial_guess_vertices[in] Optionally send in an initial guess of the pagerank values (a performance optimization). This defines the vertices. Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • initial_guess_values[in] Optionally send in an initial guess of the pagerank values (a performance optimization). Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • alpha[in] PageRank damping factor.

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in PageRank values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon.

  • max_iterations[in] Maximum number of PageRank iterations.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to pagerank results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

cugraph_error_code_t cugraph_pagerank_allow_nonconvergence(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_vertices, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_sums, const cugraph_type_erased_device_array_view_t *initial_guess_vertices, const cugraph_type_erased_device_array_view_t *initial_guess_values, double alpha, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute pagerank.

Deprecated:

This version of pagerank should be dropped in favor of the cugraph_pagerank_allow_nonconvergence version. Eventually that version will be renamed to this version.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • precomputed_vertex_out_weight_vertices[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). This defines the vertices. Set to NULL if no value is passed.

  • precomputed_vertex_out_weight_sums[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). Set to NULL if no value is passed.

  • initial_guess_vertices[in] Optionally send in an initial guess of the pagerank values (a performance optimization). This defines the vertices. Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • initial_guess_values[in] Optionally send in an initial guess of the pagerank values (a performance optimization). Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • alpha[in] PageRank damping factor.

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in PageRank values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon.

  • max_iterations[in] Maximum number of PageRank iterations.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to pagerank results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Personalized PageRank#

cugraph_error_code_t cugraph_personalized_pagerank(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_vertices, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_sums, const cugraph_type_erased_device_array_view_t *initial_guess_vertices, const cugraph_type_erased_device_array_view_t *initial_guess_values, const cugraph_type_erased_device_array_view_t *personalization_vertices, const cugraph_type_erased_device_array_view_t *personalization_values, double alpha, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute personalized pagerank.

Deprecated:

This version of personalized pagerank should be dropped in favor of the cugraph_personalized_pagerank_allow_nonconvergence version. Eventually that version will be renamed to this version.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • precomputed_vertex_out_weight_vertices[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). This defines the vertices. Set to NULL if no value is passed.

  • precomputed_vertex_out_weight_sums[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). Set to NULL if no value is passed.

  • initial_guess_vertices[in] Optionally send in an initial guess of the pagerank values (a performance optimization). This defines the vertices. Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • initial_guess_values[in] Optionally send in an initial guess of the pagerank values (a performance optimization). Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • personalization_vertices[in] Pointer to an array storing personalization vertex identifiers (compute personalized PageRank).

  • personalization_values[in] Pointer to an array storing personalization values for the vertices in the personalization set.

  • alpha[in] PageRank damping factor.

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in PageRank values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon.

  • max_iterations[in] Maximum number of PageRank iterations.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to pagerank results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

cugraph_error_code_t cugraph_personalized_pagerank_allow_nonconvergence(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_vertices, const cugraph_type_erased_device_array_view_t *precomputed_vertex_out_weight_sums, const cugraph_type_erased_device_array_view_t *initial_guess_vertices, const cugraph_type_erased_device_array_view_t *initial_guess_values, const cugraph_type_erased_device_array_view_t *personalization_vertices, const cugraph_type_erased_device_array_view_t *personalization_values, double alpha, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute personalized pagerank.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • precomputed_vertex_out_weight_vertices[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). This defines the vertices. Set to NULL if no value is passed.

  • precomputed_vertex_out_weight_sums[in] Optionally send in precomputed sum of vertex out weights (a performance optimization). Set to NULL if no value is passed.

  • initial_guess_vertices[in] Optionally send in an initial guess of the pagerank values (a performance optimization). This defines the vertices. Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • initial_guess_values[in] Optionally send in an initial guess of the pagerank values (a performance optimization). Set to NULL if no value is passed. If NULL, initial PageRank values are set to 1.0 divided by the number of vertices in the graph.

  • personalization_vertices[in] Pointer to an array storing personalization vertex identifiers (compute personalized PageRank).

  • personalization_values[in] Pointer to an array storing personalization values for the vertices in the personalization set.

  • alpha[in] PageRank damping factor.

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in PageRank values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon.

  • max_iterations[in] Maximum number of PageRank iterations.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to pagerank results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Eigenvector Centrality#

cugraph_error_code_t cugraph_eigenvector_centrality(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute eigenvector centrality.

Computed using the power method.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • epsilon[in] Error tolerance to check convergence. Convergence is measured comparing the L1 norm until it is less than epsilon

  • max_iterations[in] Maximum number of power iterations, will not exceed this number of iterations even if we haven’t converged

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to eigenvector centrality results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Katz Centrality#

cugraph_error_code_t cugraph_katz_centrality(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *betas, double alpha, double beta, double epsilon, size_t max_iterations, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute katz centrality.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • betas[in] Optionally send in a device array holding values to be added to each vertex’s new Katz Centrality score in every iteration. If set to NULL then beta is used for all vertices.

  • alpha[in] Katz centrality attenuation factor. This should be smaller than the inverse of the maximum eigenvalue of this graph

  • beta[in] Constant value to be added to each vertex’s new Katz Centrality score in every iteration. Relevant only when betas is NULL

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in Katz Centrality values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon. (L1-norm)

  • max_iterations[in] Maximum number of Katz Centrality iterations.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to katz centrality results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Betweenness Centrality#

cugraph_error_code_t cugraph_betweenness_centrality(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *vertex_list, bool_t normalized, bool_t include_endpoints, bool_t do_expensive_check, cugraph_centrality_result_t **result, cugraph_error_t **error)#

Compute betweenness centrality.

Betweenness can be computed exactly by specifying vertex_list as NULL. This will compute betweenness centrality by doing a traversal from every source vertex.

Approximate betweenness can be computed specifying a list of vertices that should be used as seeds for the traversals. Note that the function cugraph_select_random_vertices can be used to create a list of seeds.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • vertex_list[in] Optionally specify a device array containing a list of vertices to use as seeds for betweenness centrality approximation

  • normalized[in] Normalize

  • include_endpoints[in] The traditional formulation of betweenness centrality does not include endpoints when considering a vertex to be on a shortest path. Setting this to true will consider the endpoints of a path to be part of the path.

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to betweenness centrality results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Edge Betweenness Centrality#

cugraph_error_code_t cugraph_edge_betweenness_centrality(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *vertex_list, bool_t normalized, bool_t do_expensive_check, cugraph_edge_centrality_result_t **result, cugraph_error_t **error)#

Compute edge betweenness centrality.

Edge betweenness can be computed exactly by specifying vertex_list as NULL. This will compute betweenness centrality by doing a traversal from every vertex and counting the frequency that a edge appears on a shortest path.

Approximate betweenness can be computed specifying a list of vertices that should be used as seeds for the traversals. Note that the function cugraph_select_random_vertices can be used to create a list of seeds.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • vertex_list[in] Optionally specify a device array containing a list of vertices to use as seeds for betweenness centrality approximation

  • normalized[in] Normalize

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to edge betweenness centrality results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

HITS Centrality#

cugraph_error_code_t cugraph_hits(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, double epsilon, size_t max_iterations, const cugraph_type_erased_device_array_view_t *initial_hubs_guess_vertices, const cugraph_type_erased_device_array_view_t *initial_hubs_guess_values, bool_t normalize, bool_t do_expensive_check, cugraph_hits_result_t **result, cugraph_error_t **error)#

Compute hits.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • epsilon[in] Error tolerance to check convergence. Convergence is assumed if the sum of the differences in Hits values between two consecutive iterations is less than the number of vertices in the graph multiplied by epsilon.

  • max_iterations[in] Maximum number of Hits iterations.

  • initial_hubs_guess_vertices[in] Pointer to optional type erased device array containing the vertex ids for an initial hubs guess. If set to NULL there is no initial guess.

  • initial_hubs_guess_values[in] Pointer to optional type erased device array containing the values for an initial hubs guess. If set to NULL there is no initial guess. Note that both initial_hubs_guess_vertices and initial_hubs_guess_values have to be specified (or they both have to be NULL). Otherwise this will be treated as an error.

  • normalize[in] A flag to normalize the results (if set to true)

  • do_expensive_check[in] A flag to run expensive checks for input arguments (if set to true).

  • result[out] Opaque pointer to hits results

  • error[out] Pointer to an error object storing details of any error. Will be populated if error code is not CUGRAPH_SUCCESS

Returns:

error code

Centrality Support Functions#

cugraph_type_erased_device_array_view_t *cugraph_centrality_result_get_vertices(cugraph_centrality_result_t *result)#

Get the vertex ids from the centrality result.

Parameters:

result[in] The result from a centrality algorithm

Returns:

type erased array of vertex ids

cugraph_type_erased_device_array_view_t *cugraph_centrality_result_get_values(cugraph_centrality_result_t *result)#

Get the centrality values from a centrality algorithm result.

Parameters:

result[in] The result from a centrality algorithm

Returns:

type erased array view of centrality values

size_t cugraph_centrality_result_get_num_iterations(cugraph_centrality_result_t *result)#

Get the number of iterations executed from the algorithm metadata.

Parameters:

result[in] The result from a centrality algorithm

Returns:

the number of iterations

bool_t cugraph_centrality_result_converged(cugraph_centrality_result_t *result)#

Returns true if the centrality algorithm converged.

Parameters:

result[in] The result from a centrality algorithm

Returns:

True if the centrality algorithm converged, false otherwise

void cugraph_centrality_result_free(cugraph_centrality_result_t *result)#

Free centrality result.

Parameters:

result[in] The result from a centrality algorithm

cugraph_type_erased_device_array_view_t *cugraph_edge_centrality_result_get_src_vertices(cugraph_edge_centrality_result_t *result)#

Get the src vertex ids from an edge centrality result.

Parameters:

result[in] The result from an edge centrality algorithm

Returns:

type erased array of src vertex ids

cugraph_type_erased_device_array_view_t *cugraph_edge_centrality_result_get_dst_vertices(cugraph_edge_centrality_result_t *result)#

Get the dst vertex ids from an edge centrality result.

Parameters:

result[in] The result from an edge centrality algorithm

Returns:

type erased array of dst vertex ids

cugraph_type_erased_device_array_view_t *cugraph_edge_centrality_result_get_edge_ids(cugraph_edge_centrality_result_t *result)#

Get the edge ids from an edge centrality result.

Parameters:

result[in] The result from an edge centrality algorithm

Returns:

type erased array of edge ids

cugraph_type_erased_device_array_view_t *cugraph_edge_centrality_result_get_values(cugraph_edge_centrality_result_t *result)#

Get the centrality values from an edge centrality algorithm result.

Parameters:

result[in] The result from an edge centrality algorithm

Returns:

type erased array view of centrality values

void cugraph_edge_centrality_result_free(cugraph_edge_centrality_result_t *result)#

Free centrality result.

Parameters:

result[in] The result from a centrality algorithm

cugraph_type_erased_device_array_view_t *cugraph_hits_result_get_vertices(cugraph_hits_result_t *result)#

Get the vertex ids from the hits result.

Parameters:

result[in] The result from hits

Returns:

type erased array of vertex ids

cugraph_type_erased_device_array_view_t *cugraph_hits_result_get_hubs(cugraph_hits_result_t *result)#

Get the hubs values from the hits result.

Parameters:

result[in] The result from hits

Returns:

type erased array of hubs values

cugraph_type_erased_device_array_view_t *cugraph_hits_result_get_authorities(cugraph_hits_result_t *result)#

Get the authorities values from the hits result.

Parameters:

result[in] The result from hits

Returns:

type erased array of authorities values

double cugraph_hits_result_get_hub_score_differences(cugraph_hits_result_t *result)#

Get the score differences between the last two iterations.

Parameters:

result[in] The result from hits

Returns:

score differences

size_t cugraph_hits_result_get_number_of_iterations(cugraph_hits_result_t *result)#

Get the actual number of iterations.

Parameters:

result[in] The result from hits

Returns:

actual number of iterations

void cugraph_hits_result_free(cugraph_hits_result_t *result)#

Free hits result.

Parameters:

result[in] The result from hits