Community#

Triangle Counting#

cugraph_error_code_t cugraph_triangle_count(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *start, bool_t do_expensive_check, cugraph_triangle_count_result_t **result, cugraph_error_t **error)#

Triangle Counting.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • start[in] Device array of vertices we want to count triangles for. If NULL the entire set of vertices in the graph is processed

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

  • result[out] Output from the triangle_count call

  • 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

Louvain#

cugraph_error_code_t cugraph_louvain(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t max_level, double threshold, double resolution, bool_t do_expensive_check, cugraph_hierarchical_clustering_result_t **result, cugraph_error_t **error)#

Compute Louvain.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • max_level[in] Maximum level in hierarchy

  • threshold[in] Threshold parameter, defines convergence at each level of hierarchy

  • resolution[in] Resolution parameter (gamma) in modularity formula. This changes the size of the communities. Higher resolutions lead to more smaller communities, lower resolutions lead to fewer larger communities.

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

  • result[out] Output from the Louvain call

  • 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

Leiden#

cugraph_error_code_t cugraph_leiden(const cugraph_resource_handle_t *handle, cugraph_rng_state_t *rng_state, cugraph_graph_t *graph, size_t max_level, double resolution, double theta, bool_t do_expensive_check, cugraph_hierarchical_clustering_result_t **result, cugraph_error_t **error)#

Compute Leiden.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • [in/out] – rng_state State of the random number generator, updated with each call

  • max_level[in] Maximum level in hierarchy

  • resolution[in] Resolution parameter (gamma) in modularity formula. This changes the size of the communities. Higher resolutions lead to more smaller communities, lower resolutions lead to fewer larger communities.

  • theta[in] (optional) The value of the parameter to scale modularity gain in Leiden refinement phase. It is used to compute the probability of joining a random leiden community. Called theta in the Leiden algorithm.

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

  • result[out] Output from the Leiden call

  • 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

ECG#

cugraph_error_code_t cugraph_ecg(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, double min_weight, size_t ensemble_size, bool_t do_expensive_check, cugraph_hierarchical_clustering_result_t **result, cugraph_error_t **error)#

Compute ECG clustering of the given graph.

ECG runs truncated Louvain on an ensemble of permutations of the input graph, then uses the ensemble partitions to determine weights for the input graph. The final result is found by running full Louvain on the input graph using the determined weights. See https://arxiv.org/abs/1809.05578 for further information.

NOTE: This currently wraps the legacy ECG clustering implementation which is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage

  • min_weight[in] The minimum weight parameter

  • ensemble_size[in] The ensemble size parameter

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

  • result[out] The result from the clustering algorithm

  • 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

Extract Egonet#

cugraph_error_code_t cugraph_extract_ego(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, const cugraph_type_erased_device_array_view_t *source_vertices, size_t radius, bool_t do_expensive_check, cugraph_induced_subgraph_result_t **result, cugraph_error_t **error)#

Extract ego graphs.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • source_vertices[in] Device array of vertices we want to extract egonets for.

  • radius[in] The number of hops to go out from each source vertex

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

  • result[out] Opaque object containing the extracted subgraph

  • 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

Balanced Cut#

cugraph_error_code_t cugraph_balanced_cut_clustering(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t n_clusters, size_t n_eigenvectors, double evs_tolerance, int evs_max_iterations, double k_means_tolerance, int k_means_max_iterations, bool_t do_expensive_check, cugraph_clustering_result_t **result, cugraph_error_t **error)#

Balanced cut clustering.

NOTE: This currently wraps the legacy balanced cut clustering implementation and is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • n_clusters[in] The desired number of clusters

  • n_eigenvectors[in] The number of eigenvectors to use

  • evs_tolerance[in] The tolerance to use for the eigenvalue solver

  • evs_max_iterations[in] The maximum number of iterations of the eigenvalue solver

  • k_means_tolerance[in] The tolerance to use for the k-means solver

  • k_means_max_iterations[in] The maximum number of iterations of the k-means solver

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

  • result[out] Opaque object containing the clustering result

  • 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

Spectral Clustering - Modularity Maximization#

cugraph_error_code_t cugraph_spectral_modularity_maximization(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t n_clusters, size_t n_eigenvectors, double evs_tolerance, int evs_max_iterations, double k_means_tolerance, int k_means_max_iterations, bool_t do_expensive_check, cugraph_clustering_result_t **result, cugraph_error_t **error)#

Spectral clustering.

NOTE: This currently wraps the legacy spectral clustering implementation and is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • n_clusters[in] The desired number of clusters

  • n_eigenvectors[in] The number of eigenvectors to use

  • evs_tolerance[in] The tolerance to use for the eigenvalue solver

  • evs_max_iterations[in] The maximum number of iterations of the eigenvalue solver

  • k_means_tolerance[in] The tolerance to use for the k-means solver

  • k_means_max_iterations[in] The maximum number of iterations of the k-means solver

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

  • result[out] Opaque object containing the clustering result

  • 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_analyze_clustering_modularity(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t n_clusters, const cugraph_type_erased_device_array_view_t *vertices, const cugraph_type_erased_device_array_view_t *clusters, double *score, cugraph_error_t **error)#

Compute modularity of the specified clustering.

NOTE: This currently wraps the legacy spectral modularity implementation and is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • n_clusters[in] The desired number of clusters

  • vertices[in] Vertex ids from the clustering result

  • clusters[in] Cluster ids from the clustering result

  • score[out] The modularity score for this clustering

  • 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

Spectral Clustering - Edge Cut#

cugraph_error_code_t cugraph_analyze_clustering_edge_cut(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t n_clusters, const cugraph_type_erased_device_array_view_t *vertices, const cugraph_type_erased_device_array_view_t *clusters, double *score, cugraph_error_t **error)#

Compute edge cut of the specified clustering.

NOTE: This currently wraps the legacy spectral edge cut implementation and is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • n_clusters[in] The desired number of clusters

  • vertices[in] Vertex ids from the clustering result

  • clusters[in] Cluster ids from the clustering result

  • score[out] The edge cut score for this clustering

  • 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_analyze_clustering_ratio_cut(const cugraph_resource_handle_t *handle, cugraph_graph_t *graph, size_t n_clusters, const cugraph_type_erased_device_array_view_t *vertices, const cugraph_type_erased_device_array_view_t *clusters, double *score, cugraph_error_t **error)#

Compute ratio cut of the specified clustering.

NOTE: This currently wraps the legacy spectral ratio cut implementation and is only available in Single GPU implementation.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed

  • n_clusters[in] The desired number of clusters

  • vertices[in] Vertex ids from the clustering result

  • clusters[in] Cluster ids from the clustering result

  • score[out] The ratio cut score for this clustering

  • 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

Community Support Functions#

cugraph_type_erased_device_array_view_t *cugraph_triangle_count_result_get_vertices(cugraph_triangle_count_result_t *result)#

Get triangle counting vertices.

cugraph_type_erased_device_array_view_t *cugraph_triangle_count_result_get_counts(cugraph_triangle_count_result_t *result)#

Get triangle counting counts.

void cugraph_triangle_count_result_free(cugraph_triangle_count_result_t *result)#

Free a triangle count result.

Parameters:

result[in] The result from a sampling algorithm

cugraph_type_erased_device_array_view_t *cugraph_hierarchical_clustering_result_get_vertices(cugraph_hierarchical_clustering_result_t *result)#

Get hierarchical clustering vertices.

cugraph_type_erased_device_array_view_t *cugraph_hierarchical_clustering_result_get_clusters(cugraph_hierarchical_clustering_result_t *result)#

Get hierarchical clustering clusters.

double cugraph_hierarchical_clustering_result_get_modularity(cugraph_hierarchical_clustering_result_t *result)#

Get modularity.

void cugraph_hierarchical_clustering_result_free(cugraph_hierarchical_clustering_result_t *result)#

Free a hierarchical clustering result.

Parameters:

result[in] The result from a sampling algorithm