Trusted answers to developer questions

What is a spanning tree?

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

​The spanning tree of a graph (G) is a subset of G that covers all of its vertices using the minimum number of edges.

Some properties of a spanning tree can be deduced from this definition:

  1. Since “a spanning tree covers all of the vertices”, it cannot be disconnected.

  2. A spanning tree cannot have any cycles and consist of (n1)(n-1) edges (where nn is the number of vertices of the graph) because “it uses the minimum number of edges​”.

A graph can ​have more than one spanning tree. In fact, a complete graph can have a maximum of nn2n^{n-2} spanning trees.

Different possible spanning trees
Different possible spanning trees

RELATED TAGS

spanning
tree
graph
data structures
mst
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?