I need to argue that the solution found after executing the Gulous Algorithm of Prim is optimal. But I do not know how, could anyone help?
I need to argue that the solution found after executing the Gulous Algorithm of Prim is optimal. But I do not know how, could anyone help?
The Prim algorithm is to find the minimum generating tree of a graph, that is, a tree with the least possible weight of its edges. Source: Wikipedia
It begins with any arbitrary node of the graph and places it on tree A. At each subsequent step it inserts the lesser edge that has exactly one vertex inside tree A and another outside A, repeating until all of us are added
The easiest way to prove it is by contradiction . But for this you have to use the cycle property : "For any cycle C of the graph, if the weight of one edge [e] of the cycle is greater than of all other edges of the cycle, then [e] does not belong to the minimum generating tree ".
Another way to prove it is by induction . The hypothesis is that at each iteration of the algorithm, tree A is a subgraph of the minimum generating tree T.