(Latest Revision: Nov 13, 2022 )
Original list - the edges of a connected, undirected graph edge weight {07,12} 01 {01,08} 02 {07,08} 03 {01,12} 04 {08,12} 05 {03,10} 06 {05,10} 07 {03,05} 08 {05,07} 09 {01,05} 10 {05,08} 11 {03,08} 12 {06,09} 13 {04,11} 14 {01,07} 15 {02,09} 16 {02,06} 17 {08,09} 18 {08,10} 19 {06,11} 20 {09,07} 21 {04,07} 22 {04,06} 23 {06,12} 24 ------------------------------------------------------ WORK SET ONE - Kruskal List ------------------------------------------------------ Using Kruskal's Algorithm to find the edges of a minimum cost spanning tree. Initial singleton sets {01} {02} {03} {04} {05} {06} {07} {08} {09} {10} {11} {12} {07,12} 1 accept {01} {02} {03} {04} {05} {06} {07,12} {08} {09} {10} {11} 1 edge {01,08} 2 accept {01,08} {02} {03} {04} {05} {06} {07,12} {09} {10} {11} 2 edges {07,08} 3 accept {01,07,08,12} {02} {03} {04} {05} {06} {09} {10} {11} 3 edges {01,12} 4 reject {01,07,08,12} {02} {03} {04} {05} {06} {09} {10} {11} {08,12} 5 reject {01,07,08,12} {02} {03} {04} {05} {06} {09} {10} {11} {03,10} 6 accept {01,07,08,12} {02} {03,10} {04} {05} {06} {09} {11} 4 edges {05,10} 7 accept {01,07,08,12} {02} {03,05,10} {04} {06} {09} {11} 5 edges {03,05} 8 reject {01,07,08,12} {02} {03,05,10} {04} {06} {09} {11} {05,07} 9 accept {01,03,05,07,08,10,12} {02} {04} {06} {09} {11} 6 edges {01,05} 10 reject {01,03,05,07,08,10,12} {02} {04} {06} {09} {11} {05,08} 11 reject {01,03,05,07,08,10,12} {02} {04} {06} {09} {11} {03,08} 12 reject {01,03,05,07,08,10,12} {02} {04} {06} {09} {11} {06,09} 13 accept {01,03,05,07,08,10,12} {02} {04} {06,09} {11} 7 edges {04,11} 14 accept {01,03,05,07,08,10,12} {02} {04,11} {06,09} 8 edges {01,07} 15 reject {01,03,05,07,08,10,12} {02} {04,11} {06,09} {02,09} 16 accept {01,03,05,07,08,10,12} {02,06,09} {04,11} 9 edges {02,06} 17 reject {01,03,05,07,08,10,12} {02,06,09} {04,11} {08,09} 18 accept {01,02,03,05,06,07,08,09,10,12} {04,11} 10 edges {08,10} 19 reject {01,02,03,05,06,07,08,09,10,12} {04,11} {06,11} 20 accept {01,02,03,04,05,06,07,08,09,10,11,12} 11 edges {09,07} 21 {04,07} 22 {04,06} 23 {06,12} 24 ------------------------------------------------------ (Sum of the weights is 1+2+3+6+7+9+13+14+16+18+20=109) ------------------------------------------------------ ------------------------------------------------------ WORK SET TWO - Prim List ------------------------------------------------------ Using the weight-ordered edge list of the graph to find the order in which Prim's Algorithm would select the edges of a minimum cost spanning tree. {07,12} 1 Prim #3 (cheapest edge leaving S={01,07,08} Now S={01,07,08,12}) {01,08} 2 Prim #1 (cheapest edge leaving S={01} Now S={01,08}) {07,08} 3 Prim #2 (cheapest edge leaving S={01,08} Now S={01,07,08}) {01,12} 4 {08,12} 5 {03,10} 6 Prim #6 (cheapest edge leaving S={01,05,07,08,10,12} Now S={01,03,05,07,08,10,12}) {05,10} 7 Prim #5 (cheapest edge leaving S={01,05,07,08,12} Now S={01,05,07,08,10,12}) {03,05} 8 {05,07} 9 Prim #4 (cheapest edge leaving S={01,07,08,12} Now S={01,05,07,08,12}) {01,05} 10 {05,08} 11 {03,08} 12 {06,09} 13 Prim #8 (cheapest edge leaving S={01,03,05,07,08,09,10,12} Now S={01,03,05,06,07,08,09,10,12}) {04,11} 14 Prim #11 (cheapest edge leaving S={01,02,03,05,06,07,08,09,10,11,12} Now S={01,02,03,04,05,06,07,08,09,10,11,12}) {01,07} 15 {02,09} 16 Prim #9 (cheapest edge leaving S={01,03,05,06,07,08,09,10,12} Now S={01,02,03,05,06,07,08,09,10,12}) {02,06} 17 {08,09} 18 Prim #7 (cheapest edge leaving S={01,03,05,07,08,10,12} Now S={01,03,05,07,08,09,10,12}) {08,10} 19 {06,11} 20 Prim #10 (cheapest edge leaving S={01,02,03,05,06,07,08,09,10,12} Now S={01,02,03,05,06,07,08,09,10,11,12}) {09,07} 21 {04,07} 22 {04,06} 23 {06,12} 24 ------------------------------------------------------ (Same set of edges as before, same sum of the weights = 1+2+3+6+7+9+13+14+16+18+20=109) ------------------------------------------------------