Similarity Functions#

2025-05-20

3 min read time

Applies to Linux

Jaccard#

hipgraph_error_code_t hipgraph_jaccard_coefficients(
const hipgraph_resource_handle_t *handle,
hipgraph_graph_t *graph,
const hipgraph_vertex_pairs_t *vertex_pairs,
hipgraph_bool_t use_weight,
hipgraph_bool_t do_expensive_check,
hipgraph_similarity_result_t **result,
hipgraph_error_t **error,
)#

Perform Jaccard similarity computation.

Compute the similarity for the specified vertex_pairs

Note that Jaccard similarity must run on a symmetric graph.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • vertex_pairs[in] Vertex pair for input

  • use_weight[in] If true consider the edge weight in the graph, if false use an edge weight of 1

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

  • result[out] Opaque pointer to similarity results

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

Returns:

error code

Sorensen#

hipgraph_error_code_t hipgraph_sorensen_coefficients(
const hipgraph_resource_handle_t *handle,
hipgraph_graph_t *graph,
const hipgraph_vertex_pairs_t *vertex_pairs,
hipgraph_bool_t use_weight,
hipgraph_bool_t do_expensive_check,
hipgraph_similarity_result_t **result,
hipgraph_error_t **error,
)#

Perform Sorensen similarity computation.

Compute the similarity for the specified vertex_pairs

Note that Sorensen similarity must run on a symmetric graph.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • vertex_pairs[in] Vertex pair for input

  • use_weight[in] If true consider the edge weight in the graph, if false use an edge weight of 1

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

  • result[out] Opaque pointer to similarity results

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

Returns:

error code

Overlap#

hipgraph_error_code_t hipgraph_overlap_coefficients(
const hipgraph_resource_handle_t *handle,
hipgraph_graph_t *graph,
const hipgraph_vertex_pairs_t *vertex_pairs,
hipgraph_bool_t use_weight,
hipgraph_bool_t do_expensive_check,
hipgraph_similarity_result_t **result,
hipgraph_error_t **error,
)#

Perform overlap similarity computation.

Compute the similarity for the specified vertex_pairs

Note that overlap similarity must run on a symmetric graph.

Parameters:
  • handle[in] Handle for accessing resources

  • graph[in] Pointer to graph

  • vertex_pairs[in] Vertex pair for input

  • use_weight[in] If true consider the edge weight in the graph, if false use an edge weight of 1

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

  • result[out] Opaque pointer to similarity results

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

Returns:

error code

Similarty Support Functions#

hipgraph_vertex_pairs_t *hipgraph_similarity_result_get_vertex_pairs(
hipgraph_similarity_result_t *result,
)#

Get vertex pair from the similarity result.

Parameters:

result[in] The result from a similarity algorithm

Returns:

vertex pairs

hipgraph_type_erased_device_array_view_t *hipgraph_similarity_result_get_similarity(
hipgraph_similarity_result_t *result,
)#

Get the similarity coefficient array.

Parameters:

result[in] The result from a similarity algorithm

Returns:

type erased array of similarity coefficients

void hipgraph_similarity_result_free(
hipgraph_similarity_result_t *result,
)#

Free similarity result.

Parameters:

result[in] The result from a similarity algorithm