编写函数,返回一个顶点的邻接边个数
//邻接表的形式说明
typedef struct node{//边表结点
int adjvex; //邻接点域
struct node *next; //链域
//若要表示边上的权,则应增加一个数据域
}EdgeNode;
typedef struct vnode{ //顶点表结点
VertexType vertex; //顶点域
EdgeNode *firstedge;//边表头指针
}VertexNode;
typedef VertexNode AdjList[MaxVertexNum];//AdjList是邻接表类型
typedef struct ALGraph{
AdjList adjlist;//邻接表
int n,e; 图中当前顶点数和边数
}ALGraph; //对于简单的应用,无须定义此类型,可直接使用AdjList类型。
int NumNode(ALGraph Q,int i,int &e){//e返回个数
int k=0;
EdgeNode *p;
if(i>=Q.n||i<0)return error;
if(!AdjList[MaxVertexNum].firstedge)
p=AdjList[MaxVertexNum].firstedge;
while(!p->next){j++;p=p->next;}
e=j;
return e;
}
随便写得玩的
没什么基础
别见笑啊