Chào các bạn, mình mới học C nên biết được 1 số ý nghĩa các hàm. Nay nhờ các bạn giúp mình chức năng của các hàm còn lại với ạh, Cảm ơn mọi người nhiều [IMG]images/smilies/smile.png[/IMG]
Mã:
int graph::Prim(){
	 clrscr(); //xoa man hinh
	 cleardevice();  //xoa man hinh do hoa
	 if (Vertex==0)
	 cout<<"\t\tChua nhap do thi"; //in ra man hinh
	 else
	 if (check_dfs()!=1)cout<<"\tDo thi khong lien thong";         //kiem tra do thi co lien thong khong roi in ra man hinh
	 else{
	 clrscr();
	 cleardevice();
	  linesettingstype *l_info=new linesettingstype;
	  getlinesettings(l_info);
	  int colr=getcolor();
	  Set U,V;
	  vertex u,v;
	  int T[max][2];
			for(int q=0;q<max;q++){
								  T[q][0]=NILL;
								  T[q][1]=NILL;
								  }
			U.AddElem(1);
			for(int j=0;j<Vertex;j++) V.AddElem(j+1);
			int t=0;
			Set V1;
			V1=V;
			V1.RmvElem(1);
			while(U!=V){
						int min=32767;
						for(int i1=0;i1<U.Card();i1++)
						for(int i2=0;i2<V1.Card();i2++){
														int cost=a[U.Card(i1+1)-1][V1.Card(i2+1)-1];
														if ((min>cost) && (cost!=0)){
																					 min=cost;
																					 u=U.Card(i1+1);
																					 v=V1.Card(i2+1);
																					 }
														}
						U.AddElem(v);
						V1.RmvElem(v);
						T[t][0]=u;
						T[t][1]=v;
						t++;
						}
			int sum=0;
//     cout<<"
Cay bao trum toi thieu
Cac canh duoc chon la";
			for(j=0;j<max && T[j][0]!=NILL;j++){
											sum+=a[T[j][0]-1][T[j][1]-1];
								  //        cout<<"\t"<<T[j][0]<<"-"<<T[j][1];
											}
//     cout<<"
Trong luong cay la: "<<sum;
//********************************************************************
			Ve(320,240,230,3);
			setlinestyle(0,0,3);

			int x[max];
			int y[max];
			for(int i=0;i<Vertex;i++){
									  x[i]=320+cos(M_PI/180*i*(360/Vertex))*230;
									  y[i]=240-sin(M_PI/180*i*(360/Vertex))*230;
									  }
			setcolor(15);
			/*
			for(i=0;i<Vertex;i++){
								  circle(x[i],y[i],3);
								  floodfill(x[i],y[i],15);
								  outtextxy(x[i]+5,y[i]+5,int_str(i+1));
								  }
			*/
			//setlinestyle(1,0,1);
			for(j=0;j<max && T[j][0]!=NILL;j++){
											 setcolor(14);
											 getch();
											 line(x[T[j][0]-1],y[T[j][0]-1],x[T[j][1]-1],y[T[j][1]-1]);
											 /*
											 int x1=(((x[T[j][0]-1]+x[T[j][1]-1])/2)+x[T[j][0]-1])/2,y1=(((y[T[j][0]-1]+y[T[j][1]-1])/2)+y[T[j][0]-1])/2;
											 setcolor(3);
											 outtextxy(x1+5,y1+5,int_str(a[T[j][0]-1][T[j][1]-1]));
											 */
											 }
			cout<<"
Cay  khung nho nhat la: "<<sum;
			setlinestyle(l_info->linestyle,l_info->upattern,l_info->thickness);
			delete l_info;
			setcolor(colr);
			return sum;
//********************************************************************
			}

	return NILL;
}

void graph::Ve(int x_center,int y_center,int r,int linestyle){
	linesettingstype *l_info=new linesettingstype; //thuoc tinh hien tai cho boi l_info
	getlinesettings(l_info); //lay thuoc tinh hien tai cho boi l_info
	int colr=getcolor();
	cleardevice();
	setlinestyle(linestyle,0,1); //kieu duong linestyle,mau to 0, do dam 1

	if (Vertex==0) //khoi tao cho vertex=0
	outtextxy(x_center,y_center,"Chua nhap do thi"); //hien thi ra man hinh tai vi tri x_center y_center
	else {
			int x[max]; //khai bao kieu int cho x
			int y[max];
			for(int i=0;i<Vertex;i++){
									  x[i]=x_center+cos(M_PI/180*i*(360/Vertex))*r;
									  y[i]=y_center-sin(M_PI/180*i*(360/Vertex))*r;
									  }
			setcolor(15);
			for(i=0;i<Vertex;i++){
								  circle(x[i],y[i],3);
								  floodfill(x[i],y[i],15);
								  int k=7;
								  if(i>=Vertex/2){
												  settextjustify(2,1);
												  k=-k;
												  }
								   outtextxy(x[i]+k,y[i],int_str(i+1));
								  }
			settextjustify(0,0);
			for(i=0;i<Vertex;i++)
			for(int j=i+1;j<Vertex;j++)
			if (a[i][j]!=0){
							setcolor(15);
				 //			getch();
							line(x[i],y[i],x[j],y[j]);
							setcolor(3);
							int x1=(((x[i]+x[j])/2)+x[i])/2,y1=(((y[i]+y[j])/2)+y[i])/2;
							outtextxy(x1+5,y1+5,int_str(a[i][j]));
							}
		}
		setlinestyle(l_info->linestyle,l_info->upattern,l_info->thickness);
		delete l_info;
		setcolor(colr);
}