CodeArchive EulerCircuit

From Ubcacm
Revision as of 21:46, 29 January 2007 by 142.103.22.72 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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