Problem (Euler, 1736). Königsberg had four land areas joined by seven bridges. Is there a walk crossing every bridge exactly once? No: all four land areas have an odd number of bridges.

Theorem. A connected multigraph has an Euler circuit iff every degree is even, and an Euler path iff exactly 0 or 2 vertices have odd degree (the path then starts and ends at the odd ones).

int eulerKind(int n, const vector<pair<int, int>>& edges) {   // 2 = circuit, 1 = path, 0 = none (undirected multigraph)
    vector<int> deg(n, 0), p(n); iota(all(p), 0);
    function<int(int)> f = [&](int x) { return p[x] == x ? x : p[x] = f(p[x]); };
    for (auto [u, v] : edges) { deg[u]++; deg[v]++; p[f(u)] = f(v); }
    int root = -1, odd = 0;
    for (int v = 0; v < n; v++) if (deg[v]) { if (root < 0) root = f(v); else if (f(v) != root) return 0; odd += deg[v] % 2; }
    return odd == 0 ? 2 : odd == 2 ? 1 : 0;
}