ACCRA INSTITUTE OF TECHNOLOGY ADVANCE SCHOOL OF SYSTEMS AND DATA STUDIES DATA STRUCTURES AND ALGORITHMS II – CS204 SPANNING TREE PRESENTED BY GAMELI ANYAM Contents 1. Foundational Concepts 2. The Universe as a Graph 3. What is Spanning Tree? 4. Number of Possible Spanning Trees 5. Properties of Spanning Tree 6. Minimum Spanning Trees (MST) Algorithms 7. Applications of Spanning Tree Gameli Anyam Foundational Concepts Graphs are structures that consists of vertices and edges. The edges can either connect all vertices in one direction (directed) or not (undirected). Gameli Anyam Foundational Concepts 1. Complete graph: every vertex has an edge to all vertices. 2. Closed graph: number vertices equals number of edges. Gameli Anyam Foundational Concepts The Universe as a Graph N 2 1 W O 1 S E Gameli Anyam What is Spanning Tree? A spanning tree of a graph is a subgraph that contains the least number of edges needed to create a path from one vertex to another until all vertices are connected. An edge that has a numerical value is called a weighted edge. Minimum Spanning Tree (MSP) is a spanning tree with the least sum edge weights over all possible paths or spanning tree. Gameli Anyam Number of Possible Spanning Trees According to graph theory, in order to determine the number of feasible spanning trees, you must first determine the graph's type. For a cycle graph with equal number of vertices as edges, ⇒ 𝑛 𝑆𝑇 𝑐𝑦𝑙𝑒 𝑔𝑟𝑎𝑝ℎ = 𝑛 𝑉 = 𝑛 𝐸 . For a completed graph, the possible number of spanning tree is given as by; ⇒ 𝑛 𝑆𝑇 = 𝑛 𝑉 𝑉−2 . This is known as Cayley’s Formula. Gameli Anyam Properties of Spanning Tree Here are few properties of spanning tree: ❑ A spanning tree whose overall resultant weight value is minimal is considered to be a Minimal Spanning Tree. ❑ A connected graph can have more than one spanning tree. ❑ All Spanning trees must contain the same number of vertices as of graph, and the number of edges must be equal to |V| - 1. ❑ The spanning tree must not contain any cycle. Gameli Anyam MST Algorithms Most commonly used are Prim’s and Kruskal’s. Others: Reverse-deleted and Boruvka’s algorithm. Prim's Algorithm Prim's algorithm finds the subset of edges that includes every vertex of the graph such that the sum of the weights of the edges can be minimized. It starts with the single node and explore all the adjacent nodes with all the connecting edges at every step. The edges with the minimal weights causing no cycles in the graph got selected. Kruskal’s Algorithm Kruskal's Algorithm is used to find the minimum spanning tree for a connected weighted graph. Kruskal's algorithm follows greedy approach which finds an optimum solution at every stage instead of focusing on a global optimum. Gameli Anyam Applications of MST Telecommunication Network Building: If we want to develop a telecommunication network for the entire city, a basic naive approach will be more expensive. We can create a communications system at a lower cost by using the Minimum Spanning Tree technique. The image given below explains the difference between Naive and MST routing. Gameli Anyam Applications of MST Constructing Highways or Railroads: For constructing highways or railroads the Minimum Spanning Tree approach is utilized everywhere. Given the possible routes between two cities, MST technique provides you with the optimal route. Basically, the algorithm treats the cities as the vertices and paths joining them as edges to create a subtree that will make the route fully connected and cost efficient. Gameli Anyam