?? prim.h
字號:
void Prim(AdjList &G,int v,int na,int a[],WType b[])//數組a和b分別表示查找過程中選擇的頂點序列和邊的權值
{
int i,j,k;
a[0]=v;
for(i=0;i<na;i++)
{
MinWeight*p=new MinWeight[i+1];
int count=0;
for(j=0;j<=i;j++)//找出每一結點所有最小權值
{
MinWeight m;
if(GetMinWeight(G,a[j],m,a,na)==1)
p[count++]=m;
}
MinWeight *temp=p;
for(k=0;k<count;k++)//查找最小權值
if(p[k].w<temp->w)
temp=&p[k];
b[i]=temp->w;
a[i+1]=temp->dist;
delete []p;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -