40 - Data Structure & Algorithms - Spanning Tree
40 - Data Structure & Algorithms - Spanning Tree
Spanning Tree
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.
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 −
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 acyclic.
Spanning tree has n-1 edges, where n is the number of nodes (vertices).
Thus, we can conclude that spanning trees are a subset of connected Graph G
and disconnected graphs do not have spanning tree.
Spanning tree is basically used to find a minimum path to connect all nodes in
a graph. Common application of spanning trees are −
Cluster Analysis
We shall learn about two most important spanning tree algorithms here −
Kruskal's Algorithm
Prim's Algorithm