It is a subgraph of an undirected connected graph, which has a minimal set of edges connecting all of the graph's vertices. It can or cannot be weighted. As a result, a spanning tree lacks cycles, while a graph may contain numerous spanning trees. It can't be disconnected.
A minimum spanning tree (MST) is a subset of edges in a linked, weighted graph that connects all vertices with the lowest total edge weight. In other words, it is a tree that spans all of the graph's vertices while collecting the fewest edge weights.
The following algorithms are used to find a graph's minimum spanning tree:
Kruskal's algorithm creates the spanning tree by adding edges one by one. It belongs to a class of algorithms known as greedy algorithms, which seek the local optimum in the hopes of discovering a global optimum.
Prim's algorithm is a greedy algorithm that finds the shortest spanning tree for a weighted undirected graph. This means that it finds a subset of the edges that form a tree with every vertex and the lowest overall weight of all the edges in the tree.