Understand spanning tree and minimum spanning tree

    In this tutorial, you will learn about spanning tree and minimum spanning tree through examples and diagrams.
    Before learning spanning tree, we need to understand two graphs: undirected graph and connected graph.
    An undirected graph is a graph whose edges do not point in any direction (that is, the edges are bidirectional).
Insert picture description here
    An undirected graph is a
    graph that always has a path from a vertex to any other vertex.
Insert picture description here
    Connected graph

Spanning tree

    The spanning tree is a subgraph of an undirected connected graph, which contains all the vertices of the graph and the smallest possible number of edges. If a vertex is missing, it is not a spanning tree.
    The side may have weight, or it may not.
    A spanning tree can be created from a complete graph. The total number of spanning trees with n vertices is equal to n (n − 2) n^{(n-2)}n( N 2 ) .
    If n=4, the maximum possible number of spanning trees is equal to4 4 − 2 = 16 4^{4-2}=16442=1 6 . Therefore, a complete graph with 4 vertices can form 16 spanning trees.

Spanning tree example

    Let us use the following example to understand the spanning tree: The
    original diagram is:
Insert picture description here
    some possible spanning trees that can be created from the above diagram are:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Minimum spanning tree

    The minimum spanning tree is the spanning tree that is as small as possible for the sum of the weights of the edges.

Minimum spanning tree example

    Let us understand the above definition through the following example.
    The initial graph is:
Insert picture description here
    weighted graph. The
    possible spanning tree in the figure above is:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
    the minimum spanning tree of the above spanning tree is: the minimum spanning tree
Insert picture description here
    in the graph can be found using the following algorithm:

  1. Prim’s Algorithm
  2. Kruskal’s Algorithm
Spanning Tree Application
  • Computer network routing protocol
  • Cluster analysis
  • Civil network planning
Minimum spanning tree application
  • Find the route on the map
  • Design telecommunication networks, water supply networks, power grids and other networks.
Reference documents

[1]Parewa Labs Pvt. Ltd.Spanning Tree and Minimum Spanning Tree[EB/OL].https://www.programiz.com/dsa/spanning-tree-and-minimum-spanning-tree,2020-01-01.

Guess you like

Origin blog.csdn.net/zsx0728/article/details/114578537