第十三周 專案1 最小生成樹的普里姆演算法

2021-07-07 09:40:09 字數 627 閱讀 5687

/*   

* 檔名稱:main.cpp,graph.h,graph.cpp

* 完成日期:2023年11月23日  

* 版本號:vc++6.0   * 

* 問題描述:最小生成樹的普里姆演算法

* 輸入描述:  該圖為例

* 程式輸出: */

**:  (程式中graph.h是圖儲存結構的「演算法庫」中的標頭檔案,詳情請單擊鏈結…)

(1)

#include #include #include "graph.h"

void prim(mgraph g,int v)

{ int lowcost[maxv]; //頂點i是否在u中

int min;

int closest[maxv],i,j,k;

for (i=0; i

執行結果:

學習總結:

第十三周專案1 最小生成樹的普利姆演算法

標頭檔案 ifndef graph h included define graph h included define maxv 100 最大頂點個數 define inf 32767 inf表示 typedef int infotype 以下定義鄰接矩陣型別 typedef struct vert...

第十三周專案1(1)普里姆演算法的驗證

問題及 all right reserved.檔名稱 prim演算法的驗證.cpp 問題描述 輸入描述 帶權圖的鄰接矩陣 程式輸出 最小生成樹各邊的權 include include define maxv 100 最大頂點個數 define inf 32767 inf表示 typedef int ...

第十三周 專案2最小生成樹的克魯斯卡爾演算法

問題及 cpp view plain copy 檔名稱 圖 2 cpp 作 者 陳朋 完成日期 2016年12月2日 版 本 號 v1.0 問題描述 輸入描述 無 程式輸出 若干 include include include graph.h define maxsize 100 typedef s...