资 源 简 介
用prim算法实验最小生成树
本程序中用到函数adjg( ),此函数作用是通过接受输入的点数和边数,建立无向图。函数prg( )用于计算并输出无向图的邻接矩阵。函数prim( )则用PRIM算法来寻找无向图的最小生成树
定义了两个数组lowcost[max],closest[max],若顶点k加入U中,则令lowcost[k]=0。
定义二维数组g[ ][ ]来建立无向图的邻接矩阵。
-Prim algorithm using minimum spanning tree of the experimental procedures used in function adjg (), this function is through the acceptance of input points and edges, the establishment of a directed graph. Function of prg () used to calculate and output undirected graph of adjacency matrix. Function prim () is used PRIM Algorithm to find the undirected graph of the minimum spanning tree array defines two lowcost [max], closest [max], if it joined the U of k vertices, then the lowcost [k] = 0. The definition of two-dimensional array g [] [] to create a undirected graph of adjacency matrix.