1

I'm wondering how to go about solving this problem.

I'm given a graph G = (V,E). This is a connected undirected weighted graph.
The graph consists of a spanning tree and one additional edge.
How would I come up with an algorithm that would compute the MST of the graph in n = |V| time complexity.
I was thinking of Kruskal's Algorithm but it wouldn't meet the time complexity requirement.

shapiro yaacov
  • 2,308
  • 2
  • 26
  • 39
John Lee
  • 35
  • 3

1 Answers1

3

A spanning tree plus one edge makes exactly one cycle. Find the cycle using depth-first search, and then remove its heaviest edge.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87