Minimum Spanning Trees

21
Minimum Spanning Trees Presented by : M.Adnan & Alamgir

description

this is a topic of theory of automata

Transcript of Minimum Spanning Trees

  • Minimum Spanning TreesPresented by : M.Adnan & Alamgir

  • MSTA minimum spanning tree connects all nodes in a given graphA MST must be a connected and undirected graphA MST can have weighted edgesMultiple MSTs can exist within a given undirected graph

  • More about Multiple MSTsMultiple MSTs can be generated depending on which algorithm is usedIf you wish to have an MST start at a specific nodeHowever, if there are weighted edges and all weighted edges are unique, only one MST will exist

  • Real Life Application of a MSTA cable TV company is laying cable in a new neighborhood. If it is constrained to bury the cable only along certain paths, then there would be a graph representing which points are connected by those paths. Some of those paths might be more expensive, because they are longer, or require the cable to be buried deeper; these paths would be represented by edges with larger weights. A minimum spanning tree would be the network with the lowest total cost.

  • Borvkas AlgorithmThe first MST Algorithm was created by Otakar Borvka in 1926 The algorithm was used to create efficient connections between the electricity network in the Czech RepublicNo longer used since Prims and Kruskals algorithms were discovered

  • Kruskals Algorithm

    Work with edges, rather than nodesTwo steps:Sort edges by increasing edge weightSelect the first |V| 1 edges that do not generate a cycle

  • Walk-ThroughConsider an undirected, weight graph51AHBFEDCG3246343484310

  • Sort the edges by increasing edge weight51AHBFEDCG3246343484310

    edgedv(D,E)1 (D,G)2 (E,G)3 (C,D)3 (G,H)3 (C,F)3 (B,C)4

    edgedv(B,E)4 (B,F)4 (B,H)4 (A,H)5 (D,F)6 (A,B)8 (A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310Accepting edge (E,G) would create a cycle

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG3246343484310

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • Select first |V|1 edges which do not generate a cycle51AHBFEDCG2333DoneTotal Cost = dv = 21

    4}not considered

    edgedv(D,E)1(D,G)2(E,G)3(C,D)3(G,H)3 (C,F)3(B,C)4

    edgedv(B,E)4(B,F)4(B,H)4(A,H)5(D,F)6(A,B)8(A,F)10

  • THE END