Skip to content

feat: add Centroid Decomposition of a tree - #3160

Open
binarymind-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
binarymind-dev:patch-1
Open

feat: add Centroid Decomposition of a tree#3160
binarymind-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
binarymind-dev:patch-1

Conversation

@binarymind-dev

Copy link
Copy Markdown

Description

Adds Centroid Decomposition implementation to the graph/ directory.

Algorithm

Centroid Decomposition decomposes a tree by recursively finding
and removing centroids, creating a centroid tree of depth O(log N).
Used for efficient path queries on trees.

Complexity

  • Preprocessing: O(N log N)
  • Space: O(N)

Tests

  • Centroid parent structure on a path graph
  • Count paths of length 2 in a star graph
  • Count paths of length 2 in a path graph
  • Count edges (paths of length 1)
  • Single node edge case

Closes #(issue number if any)

@binarymind-dev

Copy link
Copy Markdown
Author

Hi @Panquesito7 and @realstealthninja,

Could you please approve the workflows so the CI checks can run for this PR?
I've followed the contribution guidelines. Thank you! 🙏

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Author has not responded to the comments for over 2 weeks label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Author has not responded to the comments for over 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant