python-graphblas / graphblas-algorithms

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

Improve square clustering #17

Closed eriknw closed 2 years ago

eriknw commented 2 years ago

Completely remove the old way of computing square clustering coefficients. It served its purpose.

I figured out a better way to compute uw_degrees contribution to the denominator:

uw_degrees = plus_times(A @ degrees) * (degrees - 1)

Obvious, right? I'm kidding. But, this does seem to compute degrees[u] + degrees[w] for all u-w pairs for a given node, and it's a whole lot faster than what we were doing before.

For a more detailed summary of this algorithm, see the companion PR in LAGraph: https://github.com/GraphBLAS/LAGraph/pull/133

codecov-commenter commented 2 years ago

Codecov Report

Merging #17 (ad90a6c) into main (8de0be6) will decrease coverage by 5.56%. The diff coverage is 61.42%.

@@            Coverage Diff             @@
##             main      #17      +/-   ##
==========================================
- Coverage   64.36%   58.80%   -5.57%     
==========================================
  Files          19       19              
  Lines        1333     1352      +19     
  Branches      334      343       +9     
==========================================
- Hits          858      795      -63     
- Misses        354      437      +83     
+ Partials      121      120       -1     
Impacted Files Coverage Δ
graphblas_algorithms/algorithms/cluster.py 87.23% <60.60%> (-7.07%) :arrow_down:
graphblas_algorithms/conftest.py 96.15% <75.00%> (-3.85%) :arrow_down:
...lgorithms/algorithms/link_analysis/pagerank_alg.py 17.10% <0.00%> (-72.37%) :arrow_down:
graphblas_algorithms/classes/_utils.py 61.70% <0.00%> (-5.32%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8de0be6...ad90a6c. Read the comment docs.