|
那位大哥能帮我把这程序写上注释吗?
C语言的 看的不是很懂,所以帮帮忙。
随便给我组测试的数据。谢谢
#include <stdio.h>
#include <stdlib.h>
#define MAXN 30
typedef struct
{
int v1,v2;
int weight;
}EDGE;
typedef struct
{
int Vnum;
EDGE e[MAXN*(MAXN-1)/2];
}Graph;
typedef struct node
{
int v;
struct node *next;
}Alist;
void heapadjust(EDGE data[],int s,int m) /*建立小根堆 */
{
int j;
EDGE t;
t=data;
for(j=2*s+1;j<=m;j=j*2+1)
{
if(j<m && data[j].weight>data[j+1].weight)
++j;
if(!(t.weight>data[j].weight))
break;
data=data[j];
s=j;
}
data=t;
}
int creat_graph(Graph *p)
{
int k=0;
int n;
int v1,v2;
int w;
printf("vertex number of the graph:"); /*连通图的顶点数字*/
scanf("%d",&n);
if(n<1)
exit(0);
p->Vnum=n;
do
{
printf("edge(vertex1,vertex2,weight):");
scanf("%d%d%d",&v1,&v2,&w);
if(v1>=1 && v1<=n && v2>=1 && v2<=n) /*建立图的邻接矩阵*/
{
p->e[k].v1=v1-1; |
|