以下图为例介绍Prim算法的执行过程。
Prim算法的过程从A开始 V = {A}, E = {}
选中边AF , V = {A, F}, E = {(A,F)}
选中边FB, V = {A, F, B}, E = {(A,F), (F,B)}
选中边BD, V = {A, B, F, D}, E = {(A,F), (F,B), (B,D)}
选中边DE, V = {A, B, F, D, E}, E = {(A,F), (F,B), (B,D), (D,E)}
选中边BC, V = {A, B, F, D, E, c}, E = {(A,F), (F,B), (B,D), (D,E), (B,C)}, 算法结束。