graph
graph copied to clipboard
Link/Cut-Trees implementation
This PR implements Link/Cut-Trees data structure for Boost Graph Library. Since disjoint_sets algorithms has been moved into boost/graph (#169), this should also be the right place to put link_cut_trees algorithm.
This implementation of link_cut_trees supports following operations:
-
make_tree(x)
: create a new link/cut-tree containing only rootx
-
link(x, y)
: make the tree rooted atx
a subtree ofy
; -
cut(x)
: remove the edge connectingx
to its parent; -
find_root(x)
: find the root of the tree containingx
; -
lowest_common_ancestor(x, y)
: find the lowest common ancestor of suchx
andy
that have same root.
All operations above are of amortized time complexity O(log n), except O(1) for make_tree
.
This implementation refers to: Robert Endre Tarjan, Data Structures and Network Algorithms, Chapter 5
I'm not sure that Boost.Graph really is the right place for disjoint_sets
, but it definitely is the right place for link_cut_tree
!
I just have one question: how is the documentation going? :)
@jeremy-murphy comments resolved, checks passed :)
Hi @jeremy-murphy Thanks for reviewing! This PR has been ready for quite a while. Any concerns before merging it? Would appreciate someone with write access to have a look :) @jzmaddock
Hey, sorry, I don't have much time for open-source projects now that I have a baby! I'll try to review again quickly.
@jeremy-murphy Thanks for helping review again :smile: I've replied or made changes accordingly. Enjoy parenting! :baby_bottle:
Hi @jeremy-murphy good sir, all comments resolved & checks passed, ready again :)
Hope this is not disturbing you @jzmaddock Would you mind having a look to help merge it? :))
I can't merge it, sorry, I don't have that access. @jzmaddock is the only person I'm aware of with that access and is active at the moment.
This has been lying in backlog for quite a while. @jzmaddock would you mind having a look? :)
thanks for adding this! It seems that this data structure could not be serialized using Boost: Serialization?
@jingpengw I guess it depends on the template parameters? All I know is that boost serialization supports POD and STL containers, I think you can use them to instantiate link-cut trees.
@jzmaddock Could you please take a look at this MR when you've got time? It's ready for merge :) Thank you.
@jzmaddock did you get a chance to take a look? is it good to merge?
I need to get the CI fixed and I'm going to prioritize merging some bug fixes, but then one day I'll get back to you! ;)
any chance to merge this?
any chance to merge this?
Yes, there is a chance. :) I'll try to look over it again soon, but I can't guarantee anything.
any chance to merge this?
Yes, there is a chance. :) I'll try to look over it again soon, but I can't guarantee anything.
Btw, what I meant is, I definitely want to merge it, it's just a matter of chance that I find time to do it. :)