This algorithm computes the same similarity scores as the Cosine similarity of neighborhoods, all pairs algorithm, except that it starts from all of the vertices as the source vertex and computes its similarity scores with its neighbors for all the vertices in parallel. Since this is a memory-intensive operation, it is split into batches to reduce peak memory usage. The user can specify how many batches it is to be split into. Compared with the Cosine similarity of neighborhoods, all pairs algorithm, this algorithm allows you to split the workload into multiple batches and reduces the burden on memory.
This algorithm has a time complexity of O(E), where E is the number of edges, and runs on graphs with weighted edges (directed or undirected).
The result of this algorithm is the top k cosine similarity scores and their corresponding pair for each vertex. The score is only included if it is greater than 0.
The result can be output in JSON format, in CSV to a file, or saved as a similarity edge in the graph itself.
Using the social10
graph, we can calculate the cosine similarity of every person to every other person connected by the Friend
edge, and print out the top k most similar pairs for each vertex.
Name
Description
v_type
Vertex type to calculate similarity for
e_type
Directed edge type to traverse
edge_attribute
Name of the attribute on the edge type to use as the weight
topK
Number of top scores to report for each vertex
print_accum
If true
, output JSON to standard output.
similarity_edge
If provided, the similarity score will be saved to this edge.
file_path
If not empty, write output to this file in CSV.
num_of_batches
Number of batches to divide the query into