- DSA - Discussion
- DSA - Useful Resources
- DSA - Quick Guide
- DSA - Questions and Answers
- DSA - Fibonacci Series
- DSA - Tower of Hanoi
- DSA - Recursion Basics
- DSA - Heap
- DSA - Tries
- DSA - Spanning Tree
- DSA - Splay Trees
- DSA - B+ Trees
- DSA - B Trees
- DSA - Red Black Trees
- DSA - AVL Tree
- DSA - Binary Search Tree
- DSA - Tree Traversal
- DSA - Tree Data Structure
- DSA - Breadth First Traversal
- DSA - Depth First Traversal
- DSA - Graph Data Structure
- DSA - Quick Sort
- DSA - Shell Sort
- DSA - Merge Sort
- DSA - Selection Sort
- DSA - Insertion Sort
- DSA - Bubble Sort
- DSA - Sorting Algorithms
- DSA - Hash Table
- DSA - Interpolation Search
- DSA - Binary Search
- DSA - Linear Search
- DSA - Queue
- DSA - Expression Parsing
- DSA - Stack
- DSA - Circular Linked List
- DSA - Doubly Linked List
- DSA - Linked List Basics
- DSA - Array Data Structure
- DSA - Data Structures and Types
- DSA - Data Structure Basics
- DSA - Dynamic Programming
- DSA - Divide and Conquer
- DSA - Greedy Algorithms
- DSA - Asymptotic Analysis
- DSA - Algorithms Basics
- DSA - Environment Setup
- DSA - Overview
- DSA - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Data Structure & Algorithms - Spanning Tree
A spanning tree is a subset of Graph G, which has all the vertices covered with minimum possible number of edges. Hence, a spanning tree does not have cycles and it cannot be disconnected..
By this definition, we can draw a conclusion that every connected and undirected Graph G has at least one spanning tree. A disconnected graph does not have any spanning tree, as it cannot be spanned to all its vertices.
We found three spanning trees off one complete graph. A complete undirected graph can have maximum nn-2 number of spanning trees, where n is the number of nodes. In the above addressed example, n is 3, hence 33−2 = 3 spanning trees are possible.
General Properties of Spanning Tree
We now understand that one graph can have more than one spanning tree. Following are a few properties of the spanning tree connected to graph G −
A connected graph G can have more than one spanning tree.
All possible spanning trees of graph G, have the same number of edges and vertices.
The spanning tree does not have any cycle (loops).
Removing one edge from the spanning tree will make the graph disconnected, i.e. the spanning tree is minimally connected.
Adding one edge to the spanning tree will create a circuit or loop, i.e. the spanning tree is maximally acycpc.
Mathematical Properties of Spanning Tree
Spanning tree has n-1 edges, where n is the number of nodes (vertices).
From a complete graph, by removing maximum e - n + 1 edges, we can construct a spanning tree.
A complete graph can have maximum nn-2 number of spanning trees.
Thus, we can conclude that spanning trees are a subset of connected Graph G and disconnected graphs do not have spanning tree.
Apppcation of Spanning Tree
Spanning tree is basically used to find a minimum path to connect all nodes in a graph. Common apppcation of spanning trees are −
Civil Network Planning
Computer Network Routing Protocol
Cluster Analysis
Let us understand this through a small example. Consider, city network as a huge graph and now plans to deploy telephone pnes in such a way that in minimum pnes we can connect to all city nodes. This is where the spanning tree comes into picture.
Minimum Spanning Tree (MST)
In a weighted graph, a minimum spanning tree is a spanning tree that has minimum weight than all other spanning trees of the same graph. In real-world situations, this weight can be measured as distance, congestion, traffic load or any arbitrary value denoted to the edges.
Minimum Spanning-Tree Algorithm
We shall learn about two most important spanning tree algorithms here −
Both are greedy algorithms.
Advertisements