Skip to content

Conversation

@vama-tg
Copy link

@vama-tg vama-tg commented Nov 6, 2025

PR Summary

  • ZENDESK_TICKET
    • Customer faced the divide by zero error and wants a fix to be added to the algorithm in the library.

PR Checklist

  • Added comments for more comprehensible code.
  • Added unit and/or regression tests.
  • (Optional) Notified Doc/Prod team, if this PR contains any new features.

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_values is non-zero.

Other information:

Related PRs:


Note

Add zero-check before normalizing eigenvector scores to prevent divide-by-zero and fix CSV header typo.

  • Eigenvector Centrality (algorithms/Centrality/eigenvector/tg_eigenvector_cent.gsql):
    • Add conditional check to only divide by sqrt(@@sum_squares_eigen_values) when @@sum_squares_eigen_values > 0 to avoid divide-by-zero during normalization.
    • Correct CSV header label from "egien vector" to "eigen vector".

Written by Cursor Bugbot for commit e0e11c3. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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.

2 participants