feat: add approximate triangle counting algorithm using DataSketches#789
Merged
SemyonSinchenko merged 5 commits intoFeb 3, 2026
Merged
Conversation
This introduces a new "approx" algorithm for triangle counting that leverages Apache Spark's DataSketches (Theta sketches) integration (available since Spark 4.1). This provides a scalable alternative to the existing "exact" implementation, which often encounters Out-of-Memory (OOM) issues on power-law graphs with high-degree nodes. Changes include: - Core: Added `approximateRun` to `TriangleCount.scala` using `theta_sketch_agg` and `theta_intersection`. - Core: Added `GraphFramesRequireSpark` exception for feature gating. - Connect: Updated protobuf definition and Scala/Python logic to support `algorithm` and `lg_nom_entries` parameters. - Python: Updated `triangleCount` API in both classic and connect implementations to support the new parameters. - Docs: Expanded the traversal guide with a detailed comparison between exact and approximate implementations and usage guidelines. - Tests: Added Scala and Python test suites for the approximate algorithm. Closes graphframes#786
james-willis
requested changes
Feb 2, 2026
james-willis
requested changes
Feb 2, 2026
james-willis
approved these changes
Feb 2, 2026
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #789 +/- ##
==========================================
- Coverage 84.90% 83.75% -1.15%
==========================================
Files 68 68
Lines 3444 3539 +95
Branches 431 415 -16
==========================================
+ Hits 2924 2964 +40
- Misses 520 575 +55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This introduces a new "approx" algorithm for triangle counting that leverages Apache Spark's DataSketches (Theta sketches) integration (available since Spark 4.1). This provides a scalable alternative to the existing "exact" implementation, which often encounters Out-of-Memory (OOM) issues on power-law graphs with high-degree nodes.
Changes include:
approximateRuntoTriangleCount.scalausingtheta_sketch_aggandtheta_intersection.GraphFramesRequireSparkexception for feature gating.algorithmandlg_nom_entriesparameters.triangleCountAPI in both classic and connect implementations to support the new parameters.Why are the changes needed?
Closes #786