CodeArchive EulerCircuit

From Ubcacm
Jump to: navigation, search

Euler Circuit

This code works for undirected/undirected graph (but not both). For mixed graph, run a Maximum Flow to fix most of the edges and run this algorithm again. We should consider directed edges (fixed) before undirected ones.

void recur(int now, list < int > :: iterator iter){
  for(int i = 0; i < n; i++)
    if(g[now][i]) g[now][i]--, recur(i, ans.insert(iter, i));
}
// ans.clear(), recur(0, ans.begin());

-- Main.YuryKholondyrev - 17 Nov 2005