Skip to content

15 link prediction - #116

Open
eriknw wants to merge 1 commit into
python-graphblas:dispatch-followupsfrom
eriknw:15-link-prediction
Open

eriknw wants to merge 1 commit into
python-graphblas:dispatch-followupsfrom
eriknw:15-link-prediction

Conversation

@eriknw

@eriknw eriknw commented Dec 2, 2026

Copy link
Copy Markdown
Member

Add the link prediction scores. The common-neighbor ones come from one masked product of the adjacency with its transpose; preferential_attachment and common_neighbor_centrality are computed from degrees and pair distances. They follow NetworkX's generator semantics and ordering of pairs.

  • jaccard_coefficient, adamic_adar_index, resource_allocation_index, preferential_attachment, common_neighbor_centrality (a non-numeric alpha other than 1 is declined)
  • The three scores that read a community node attribute are left to NetworkX

Stacked on #115.

Add jaccard_coefficient, adamic_adar_index, resource_allocation_index,
preferential_attachment and common_neighbor_centrality.

The common neighbors of every pair come from one product, A @ A.T,
masked by the distinct pairs so that no other entry is formed; with
each column weighted by 1 / degree or 1 / log(degree) the same product
gives the two sums. common_neighbor_centrality with an alpha other
than 1 adds a breadth-first search from each distinct node at the end
of the pairs that has fewer of them.

The answers are NetworkX's: a generator that checks ebunch when called
and scores when read, so an iterator ebunch is used up by the check;
the int 0 where NetworkX sums nothing; a self-loop counted twice in a
degree; and a pair that cannot be scored raising only when reached.
Without an ebunch the pairs come in the order of nx.non_edges, each
node's partners scored together. The three scores that read a
community node attribute are left to NetworkX.
@eriknw eriknw mentioned this pull request Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.37759% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.01%. Comparing base (b297a0a) to head (f312357).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           dispatch-followups     #116      +/-   ##
======================================================
+ Coverage               91.63%   92.01%   +0.37%     
======================================================
  Files                     161      165       +4     
  Lines                    9601    10083     +482     
  Branches                 1154     1186      +32     
======================================================
+ Hits                     8798     9278     +480     
- Misses                    554      556       +2     
  Partials                  249      249              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant