t += minCost; chosen[edgeIndex++] = *minEdge; cout << minEdge->ame <<"->"<< minEdge->adjName <<endl;// 输出这条最小权重的表 visitedNodes[visitedIndex++] = minEdge->adjvex; }} 4. 主函数 int main() { printf(" 试验名称:管道铺设施工的最佳方案问题\n"); printf(" 学号: 031350103\n"); printf(" 姓名: \n"); printf("=========================================================\n"); time_t rawtime1; struct tm* timeinfo1; time (&rawtime1); timeinfo1 = localtime (&rawtime1); // 时间函数; printf (" 程序运行开始, 当前日期和时间: %s", asctime(timeinfo1)); ALGraph* G= (ALGraph*)malloc(sizeof(ALGraph)); create(G); cout <<" 建立的图邻接表表示为: "<<endl; for (int i= 0;i< G->n;i++) { EdgeNode *p= G->adjlist[i].firstedge; printf("%d->", i); // 输出建立的邻接表 while (p != NULL) { printf("%d->", p->adjvex); p= p->next; } printf("\n"); } printf(" 应用 prim 算法,得到的最小生成树是: "); prime(G, 0);