Community#
2025-05-20
9 min read time
Triangle Counting#
- rocgraph_status rocgraph_triangle_count(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- const rocgraph_type_erased_device_array_view_t *start,
- rocgraph_bool do_expensive_check,
- rocgraph_triangle_count_result_t **result,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Louvain#
- rocgraph_status rocgraph_louvain(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- size_t max_level,
- double threshold,
- double resolution,
- rocgraph_bool do_expensive_check,
- rocgraph_hierarchical_clustering_result_t **result,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Leiden#
- rocgraph_status rocgraph_leiden(
- const rocgraph_handle_t *handle,
- rocgraph_rng_state_t *rng_state,
- rocgraph_graph_t *graph,
- size_t max_level,
- double resolution,
- double theta,
- rocgraph_bool do_expensive_check,
- rocgraph_hierarchical_clustering_result_t **result,
- rocgraph_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
rng_state – [inout] 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 ROCGRAPH_SUCCESS
- Returns:
error code
ECG#
- rocgraph_status rocgraph_ecg(
- const rocgraph_handle_t *handle,
- rocgraph_rng_state_t *rng_state,
- rocgraph_graph_t *graph,
- double min_weight,
- size_t ensemble_size,
- size_t max_level,
- double threshold,
- double resolution,
- rocgraph_bool do_expensive_check,
- rocgraph_hierarchical_clustering_result_t **result,
- rocgraph_error_t **error,
Compute ECG clustering.
- Parameters:
handle – [in] Handle for accessing resources
rng_state – [inout] State of the random number generator, updated with each call
graph – [in] Pointer to graph. NOTE: Graph might be modified if the storage needs to be transposed
min_weight – [in] Minimum edge weight in final graph
ensemble_size – [in] The number of Louvain iterations to run
max_level – [in] Maximum level in hierarchy for final Louvain
threshold – [in] Threshold parameter, defines convergence at each level of hierarchy for final Louvain
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 ROCGRAPH_SUCCESS
- Returns:
error code
Extract Egonet#
- rocgraph_status rocgraph_extract_ego(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- const rocgraph_type_erased_device_array_view_t *source_vertices,
- size_t radius,
- rocgraph_bool do_expensive_check,
- rocgraph_induced_subgraph_result_t **result,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Balanced Cut#
- rocgraph_status rocgraph_balanced_cut_clustering(
- const rocgraph_handle_t *handle,
- rocgraph_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,
- rocgraph_bool do_expensive_check,
- rocgraph_clustering_result_t **result,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Spectral Clustering - Modularity Maximization#
- rocgraph_status rocgraph_spectral_modularity_maximization(
- const rocgraph_handle_t *handle,
- rocgraph_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,
- rocgraph_bool do_expensive_check,
- rocgraph_clustering_result_t **result,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
- rocgraph_status rocgraph_analyze_clustering_modularity(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- size_t n_clusters,
- const rocgraph_type_erased_device_array_view_t *vertices,
- const rocgraph_type_erased_device_array_view_t *clusters,
- double *score,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Spectral Clustering - Edge Cut#
- rocgraph_status rocgraph_analyze_clustering_edge_cut(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- size_t n_clusters,
- const rocgraph_type_erased_device_array_view_t *vertices,
- const rocgraph_type_erased_device_array_view_t *clusters,
- double *score,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
- rocgraph_status rocgraph_analyze_clustering_ratio_cut(
- const rocgraph_handle_t *handle,
- rocgraph_graph_t *graph,
- size_t n_clusters,
- const rocgraph_type_erased_device_array_view_t *vertices,
- const rocgraph_type_erased_device_array_view_t *clusters,
- double *score,
- rocgraph_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 ROCGRAPH_SUCCESS
- Returns:
error code
Community Support Functions#
- rocgraph_type_erased_device_array_view_t *rocgraph_hierarchical_clustering_result_get_vertices(
)#
Get hierarchical clustering vertices.
- rocgraph_type_erased_device_array_view_t *rocgraph_hierarchical_clustering_result_get_clusters(
)#
Get hierarchical clustering clusters.
- double rocgraph_hierarchical_clustering_result_get_modularity(
)#
Get modularity.
- void rocgraph_hierarchical_clustering_result_free(
)#
Free a hierarchical clustering result.
- Parameters:
result – [in] The result from a sampling algorithm
- rocgraph_type_erased_device_array_view_t *rocgraph_triangle_count_result_get_vertices(
)#
- rocgraph_triangle_count_result_t *result,
Get triangle counting vertices.
- rocgraph_type_erased_device_array_view_t *rocgraph_triangle_count_result_get_counts(
)#
- rocgraph_triangle_count_result_t *result,
Get triangle counting counts.
- void rocgraph_triangle_count_result_free(
)#
- rocgraph_triangle_count_result_t *result,
Free a triangle count result.
- Parameters:
result – [in] The result from a sampling algorithm
- struct rocgraph_clustering_result_t#
#include <rocgraph_clustering_result_t.h>Opaque clustering output.
Public Members
- int32_t align_#
alignment variable