欧拉图 节点度为0或2 半欧拉两个结点度为奇数,其他偶数。 同时要保证其为连通图(任意两个结点能走到)
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
const int maxn = 501;
vector<int>v[maxn];
bool visit[maxn];
int cnt = 0;
void dfs(int index)
{
visit[index] = true;
cnt++;
for (int i = 0; i < v[index].size(); i++)
{
if (visit[v[index][i]] == false)
dfs(v[index][i]);
}
}
int main()
{
int n, m, a, b, even = 0;
cin >> n >> m;
for (int i = 0; i < m; i++)
{
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
for (int i = 1; i <= n; i++)
{
if (i!=1) cout << " ";
cout << v[i].size();
if (v[i].size() % 2 == 0) even++;
}
cout << endl;
dfs(1);
if (even == n && cnt == n)
cout << "Eulerian" << endl;
else if (even == n - 2 && cnt == n)
printf("Semi-Eulerian");
else
printf("Non-Eulerian");
return 0;
}