A thresholded similarity graph is a set of nodes and edges, where nodes are connected by an edge iff the similarity between the two nodes is higher than a given threshold.
Building such graph of n
nodes is easy: create a n x n
matrix M
, place each node in both the column and the rows, then fill each cell C[i,j]
with the similarity between the node i
and node j
iff the result is higher than the given threshold. The complexity here is obviously O(n^2)
.
This complexity can be slightly improved by not computing C[i, j]
if i == j
, or if C[j, i]
has already been computed (assuming that the similarity between nodes i
and j
is the same than the similarity between nodes j
and i
). However, the complexity being then O(n * (n - 1) / 2)
is still equivalent to O(n^2)
.
Given that the similarity function used is either a metric or a the cosine similarity (although this info may not be relevant), is there a way to compute such thresholded similarity graph with a complexity better than O(n^2)
?
Thanks, Romain.