Skip to content

Conversation

@storrealbac
Copy link
Collaborator

Implemented the optimized Edmonds/Chu-Liu algorithm for finding minimum spanning arborescence using lazy skew heaps.

Implemented the optimized Edmonds/Chu-Liu algorithm for finding minimum spanning arborescence using lazy skew heaps.
Updated comments for clarity and formatting.
Updated comment to clarify return value when not reachable.
@CharlesLakes
Copy link
Contributor

Test fallido, por favor corregir.

Saludos!

Updated comments to clarify complexity and status.
@storrealbac storrealbac merged commit 24c9810 into master Jan 27, 2026
2 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optimized Minimum Spanning Arborescence (directed MST) implementation using an Edmonds/Chu–Liu variant with lazy skew heaps, and registers it in the content tracker.

Changes:

  • Added fast-chu-liu.cpp implementing an O(E log V) directed MST algorithm returning both total weight and parent array.
  • Updated tracker.yaml to include the new snippet under graphs/misc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tracker.yaml Registers the new directed MST snippet in the content index.
content/graphs/misc/fast-chu-liu.cpp Introduces the optimized Chu–Liu/Edmonds implementation using lazy skew heaps + rollback DSU.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc = merge(cyc, heap[w = path[--qi]]);
while (uf.unionSet(u, w));
u = uf.findSet(u), heap[u] = cyc, seen[u] = -1;
cycs.push_front({u, t, {&Q[qi], &Q[end]}});
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The pointer expression &Q[end] is undefined behavior when end == Q.size() (it uses operator[] one-past-the-end). This can happen when qi reaches n on a long path. Construct the subrange using iterators (e.g., Q.begin() + qi / Q.begin() + end) or Q.data() + end to safely represent the end iterator.

Suggested change
cycs.push_front({u, t, {&Q[qi], &Q[end]}});
cycs.push_front({u, t, vector<edge>(Q.begin() + qi, Q.begin() + end)});

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +6
/*
*Description:* Minimum spanning arborescence (directed MST), optimized Edmonds/Chu-Liu algorithm using lazy skew heaps
*Complexity:* $O(E log V)$, returns $(-1, emptyset)$ if not reachable
*Status:* Tested (Fastest Speedrun)
*/
template <class T> struct fast_chu_liu {
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Header comment formatting is inconsistent with other snippets (each line typically starts with *). Lines 3 and 6 currently miss the leading */spacing, which breaks the standard metadata parser/style used elsewhere (e.g., content/graphs/misc/chu-liu.cpp:1-5). Please align the block comment formatting to match the repository convention.

Copilot uses AI. Check for mistakes.
@storrealbac
Copy link
Collaborator Author

Test fallido, por favor corregir.

Saludos!

enfermito

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.

3 participants