图G的一个回路,若它恰通过G中每条边一次,则称该回路为欧拉(Euler)回路,具有欧拉回路的图称为欧拉图。
1.无向图中:所给定的图为连通图,且所有节点的度为偶数
1.无向图中:所给定的图为连通图,且所有节点的度为偶数
2.有向图中:所给定的图为连通图,且所有节点的度为零
欧拉路径但非欧拉回路:
1.无向图中:所给定的图为连通图,只有两个点的度为奇数,其他为偶数
2.有向图中:所给定的图为连通图,只有两个点的度为1,其他为零
#include <cstdio>
#include <cstring>
#include <iostream>
int map[1005][1005];
int book[10005];
int degree[1005];
int count;
int n,m;
using namespace std;
int JudgeIndegree(){
for(int i=1;i<=n;i++)
if(degree[i]%2!=0)
return 0;
return 1;
}
void DFS(int x){
count++;
for(int i=1;i<=n;i++){
if(!book[i]&&map[x][i]){
book[i]=1;
DFS(i);
}
}
return;
}
int main(){
int x,y;
while(cin>>n>>m){
count=0;
memset(map,0,sizeof(map));
memset(book,0,sizeof(book));
memset(degree,0,sizeof(degree));
for(int i=1;i<=m;