我在大学里遇到了以下问题:
让G =(V,E)为(无向)图与成本Ç Ë上边缘> = 0 Ë ∈ Ë.假设给你一个最低成本生成树牛逼的摹.现在假设一个新的边缘被添加到ģ,连接两个节点v,吨v ∈ V与成本Ç.
这是我找到的解决方案:
Let e1=(a,b) the new edge added
Find in T the shortest path from a to b (BFS)
if e1 is the most expensive edge in the cycle then T remains …Run Code Online (Sandbox Code Playgroud)