python-graphblas / graphblas-algorithms

Graph algorithms written in GraphBLAS
Apache License 2.0
76 stars 4 forks source link

Alternative for square counting (for square clustering) #13

Closed eriknw closed 2 years ago

eriknw commented 2 years ago

Inspired from this paper, https://arxiv.org/pdf/2007.11111.pdf, we can compute square counting for all nodes via:

    Q(~degrees.diag().S) << plus_pair(A @ A)  # Use mask to ignore diagonal
    all_squares = (Q * (Q - 1)).reduce_rowwise() // 2

This is probably better than counting squares one node at a time.

Now, can we come up with a better way to compute the denominator?