How we find MST (Minimum Spanning Tree) after add new node or change distance of ways?
I need help to solve this. Can anybody help me?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When adding new edges:
You will need to perform a graph traversal, the easiest is DFS for this, from one of the sides of the modified/new edge. If you can back to a node you were to before, you have a cycle.
In that cycle, you will need to remove the largest edge. You will get a tree again, and it is the minimal spanning one.
If you are changing edge weights, you will need to:
Again, you get a new minimal spanning tree.
Overall, this is
O(V+E), times a small factor of inverse Ackermann.