Update tg_eigenvector_cent.gsql to add check for divide by zero error#182
Update tg_eigenvector_cent.gsql to add check for divide by zero error#182vama-tg wants to merge 2 commits intotg_4.3.0_devfrom
Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Comment @cursor review or bugbot run to trigger another review on this PR
| IF @@sum_squares_eigen_values > 0 THEN | ||
| s.@sum_eigen_value = s.@sum_eigen_value / sqrt(@@sum_squares_eigen_values) | ||
| END, | ||
| @@sum_cur_norm_values += s.@sum_eigen_value; |
There was a problem hiding this comment.
Bug: Convergence Breaks from Inconsistent Normalization Logic
The divide-by-zero fix introduces a logic error in the convergence calculation. When @@sum_squares_eigen_values <= 0, the normalization step (line 73) is skipped, but line 75 still adds the unnormalized s.@sum_eigen_value to @@sum_cur_norm_values. This causes inconsistent behavior: normalized values are accumulated when @@sum_squares_eigen_values > 0, but unnormalized values are accumulated otherwise. This breaks the convergence calculation logic. The accumulation on line 75 should either be inside the IF block, or the algorithm should handle the zero case differently to maintain consistency.
PR Summary
divide by zeroerror and wants a fix to be added to the algorithm in the library.PR Checklist
What is the behavior change?
There is a check in the query that makes sure to perform the division only when the value of
@@sum_squares_eigen_valuesis non-zero.Other information:
Related PRs:
Note
Add zero-check before normalizing eigenvector scores to prevent divide-by-zero and fix CSV header typo.
algorithms/Centrality/eigenvector/tg_eigenvector_cent.gsql):sqrt(@@sum_squares_eigen_values)when@@sum_squares_eigen_values > 0to avoid divide-by-zero during normalization."egien vector"to"eigen vector".Written by Cursor Bugbot for commit e0e11c3. Configure here.