bool Istree() { bool f=1; int component=0; int root=0; for(int i=0; i<Max; i++) { if(!visit[i]) { continue; } if(i==father[i]) { component++; } if(Indegree[i]==0) { root++; } else if(Indegree[i]>1) { f=0; } } if(component!=1||root!=1) { f=0; } if(component==0&;&;root==0) { f=1; } return f; } 判断为树,一个根结点,度为0,其余结点度为1,各个结点同属一个集合!!!
点赞 评论

相关推荐

昨天 18:11
门头沟学院 Java
想要实习的牛:这么牛逼的简历都吃瘪吗🌚那我不寄了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务