I want to make a dynamic minimum spanning tree. I have an existing MS tree over n vertices and I add one more vertex and edges to all the existing vertices from this new vertex. How can I update the MST for the new graph efficiently? O(n) would be optimal. Can I also make delete vertex operation efficient?
相关问题
- Finding k smallest elements in a min heap - worst-
- binary search tree path list
- High cost encryption but less cost decryption
- How to get a fixed number of evenly spaced points
- Space complexity of validation of a binary search
相关文章
- What are the problems associated to Best First Sea
- Oracle equivalent of PostgreSQL INSERT…RETURNING *
- Coin change DP solution to keep track of coins
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- How to measure complexity of a string?
- Select unique/deduplication in SSE/AVX
O(n log n)
using Kruskal's algorithm. The key idea is any edges not used in the original MST will not be used in the new MST either. So just sort then
new edgesO(n log n)
, merge this sorted list with the list of edges of the old MST (which you kept in sorted order, right?)O(n)
, then run Kruskal's algorithm anew on the resulting sorted list of edgesO(n)-ish
.