Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Finding the number of spanning trees in a graph
The article is already well-structured and clean from the previous improvement. I'll replace the two JPG images with SVG diagrams and keep everything else intact.
A spanning tree of a connected graph G is a subgraph that includes all the vertices of G and is a tree (connected with no cycles). A spanning tree with n vertices always has exactly n − 1 edges. A single graph can have multiple spanning trees, and finding the total count is a common problem in graph theory.
How to Find Spanning Trees
To find all spanning trees of a graph, systematically remove edges one at a time (or in combinations) such that the resulting subgraph −
- Contains all vertices of the original graph
- Remains connected
- Has no cycles (i.e., has exactly n − 1 edges for n vertices)
Problem Statement
Find the number of spanning trees in the following graph ?
Solution
The original graph has 3 vertices and 3 edges (forming a triangle/cycle). A spanning tree on 3 vertices must have exactly 3 − 1 = 2 edges. Since the graph has 3 edges, we remove one edge at a time to get each spanning tree.
The number of spanning trees obtained from the above graph is 3. They are as follows −
Each spanning tree is formed by removing a different edge from the original triangle −
| Spanning Tree | Edge Removed | Edges Kept |
|---|---|---|
| Tree I | e3 (b–c) | e1 (a–b), e2 (a–c) |
| Tree II | e2 (a–c) | e1 (a–b), e3 (b–c) |
| Tree III | e1 (a–b) | e2 (a–c), e3 (b–c) |
Among these three spanning trees, Trees I and II are isomorphic to each other (both have vertex 'a' as the center with degree 2). Tree III has a different structure (vertex 'c' is the center). Therefore, the number of non-isomorphic spanning trees is 2.
Conclusion
The given graph has 3 spanning trees in total, of which 2 are structurally distinct (non-isomorphic). For any cycle graph Cn, the number of spanning trees is always n, since removing any one of the n edges produces a valid spanning tree.
