文章
126
粉丝
35
获赞
0
访问
25.0k
(1)统计所有顶点的出度和入度,若存在边(i,j),G.Edge[i][j]=1,
顶点i的出度,定点j的入度均+1;否则,出度,入度均不变。
(2)int printVertices(MGraph G){
int indegrees[G.numVertices];
int outdegrees[G.numVertices];
memset(indegrees, 0, sizeof(indegrees));
memset(outdegrees, 0, sizeof(outdegrees));
for(int i=0;i<G.numVertices;i++){
for(int j=0;j<G.numVertices;j++){
outdegrees[i] += G.Edge[i][j];
indegrees[j] += G.Edge[i][j];
}
}
int t=0;
for(int i=0;i<G.numVertices;i++){
if(outdegrees[i]>indegrees[i]){
t++;
}
}
return t;
}
登录后发布评论
暂无评论,来抢沙发