无向图求欧拉回路:
1、图连通
2、所有顶点的度数位偶数
随便从一个点开始递归遍历即可求出路径
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int maxcolor = 50;
int n, G[maxcolor+1][maxcolor+1], deg[maxcolor+1];
struct Edge{
int from, to;
Edge(int from, int to):from(from), to(to){
}
};
vector<Edge> ans;
void euler(int u){
for(int v=1; v<=maxcolor; v++) if(G[u][v]){
G[u][v]--; G[v][u]--;
euler(v);
ans.push_ba......
阅读全文