普里姆算法最小生成树
What to Learn?
学什么?
How to construct minimum spanning tree using Prim's Minimum Spanning Tree algorithm and its C++ implementation?
如何使用Prim的最小生成树算法及其C ++实现构造最小生成树?
Minimum Spanning Tree is a tree with all the vertices of the graph and who has a minimum weight.
最小生成树是具有图形的所有顶点且权重最小的树。
In the figure there is a graph with 9 vertexes.
图中有一个具有9个顶点的图形。

If we construct a minimum spanning tree then it would be like,
如果我们构造一个最小生成树,那么它将是,

Algorithm:
算法:
To implement the Prim's Minimum Spanning Tree algorithm, we have an array of all the vertices with their corresponding distance.
为了实现Prim的最小生成树算法 ,我们有一个所有顶点及其对应距离的数组。
Initially, all the vertices have a distance infinity except the starting vertex which has distance zero.
最初,除起始顶点的距离为零外,所有顶点的距离都为无穷大。
We check the all the unvisited reachable vertices from the starting vertex and update all the distance with weighted edge distance from that vertex.
我们从起始顶点检查所有未访问的可达顶点,并使用从该顶点开始的加权边距更新所有距离。
Choose the minimum unvisited distance and choose the corresponding vertex.