<!– /* Font Definitions */ @font-face {font-family:”Cambria Math”; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:”"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:”Calibri”,”sans-serif”; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:”Times New Roman”; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:”";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:”Times New Roman”;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
void kruskal ( )
{
int i,x,b[MAX_NODE],top,w,v;
int min_wt,y,f_wt[MAX_NODE],bentuk;
node *ptr1;
f_node *ptr2;
f_list=NULL;
for(i=1;i<=totNodes;i++)
status[i]=unseen;
x=1;
status[x]=intree;
top=0;
bentuk=0;
while( (top <= (totNodes-1)) && (!bentuk
{
ptr1=adj[x];
while(ptr1!=NULL)
{
y=ptr1->vertex;
w=ptr1->weight;
if((status[y]==fringe) && (w<f_wt[y]))
{
b[y]=x;
f_wt[y]=w;
}
else if(status[y]==unseen)
{
status[y]=fringe;
b[y]=x;
f_wt[y]=w;
Insert_Beg(y);
}
ptr1=ptr1->next;
}
if(f_list==NULL)
bentuk=1;
else
{
x=f_list->vertex;
min_wt=f_wt[x];
ptr2=f_list->next;
while(ptr2!=NULL)
{
w=ptr2->vertex;
if(f_wt[w] < min_wt)
{
x=w;
min_wt=f_wt[w];
}
ptr2=ptr2->next;
}
del(x);
status[x]=intree;
top++;
}
}
for(x=2;x<=totNodes;x++)
cout<<”(“<<x<<”,”<<b[x]<<”)\n”;
delay(10);
}