Solution

ID: past-exam-of-the-integer-programming-course-of-the-university-of-oxford/2011/1/b/solution

Use the maximum-weight version of Kruskal's algorithm: sort the edges by decreasing weight, start with no edges, and add an edge exactly when it joins different current connected components of a graph. For the maximum over all forests, skip negative-weight edges; removing a negative edge always preserves a forest and increases its weight. Zero-weight edges are optional. The matroid greedy algorithm for the graphic matroid proves this procedure optimal; it maximizes over independent sets rather than requiring a full basis.
The positive edges are considered in the order
Admit and . Reject , since it closes the triangle on . Admit . Reject , since and are already joined by the path . Skip both negative edges incident with vertex four. Therefore
Vertex four is isolated. Requiring a spanning tree would force a negative edge and solve a different optimization problem. With a disjoint-set data structure, sorting dominates the running time, giving .

New to topics? Read the docs here!