The graph is a set of vertices connected with the help of edges. A graph may be directed or undirected, and all the vertices are connected in the graph. We can represent a graph using an array of vertices and a two-dimensional array for edges. We can perform basic operations on graphs: adding a vertex, displaying vertex, adding edges, etc.
A spanning tree is a tree that connects all the vertices of the graph and the lower number of edges. Therefore, the spanning tree is always connected. Also, the spanning tree has never had a cycle. A spanning tree is always defined by a graph and remains a subset of that graph. Thus, a disconnected graph can never have a spanning tree.
Each graph is not directed and connected to a minimum of one opening tree. Consider a graph with V vertices and E number of edges. After that, we will represent a graph like G (V, E). Its open tree will be represented as G ’(V, E’), where E ’⊆ E and the number of vertices remain the same. Therefore, the tree that produces G’s is a G-branch with its own set of the same vertex, but the edges may differ.