MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / euler

Function euler

code/graph/euler_path_undirected.cpp:3–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1multiset<int> adj[1010];
2list<int> L;
3list<int>::iterator euler(int at, int to,
4 list<int>::iterator it) {
5 if (at == to) return it;
6 L.insert(it, at), --it;
7 while (!adj[at].empty()) {
8 int nxt = *adj[at].begin();
9 adj[at].erase(adj[at].find(nxt));
10 adj[nxt].erase(adj[nxt].find(at));
11 if (to == -1) {
12 it = euler(nxt, at, it);
13 L.insert(it, at);
14 --it;
15 } else {
16 it = euler(nxt, to, it);
17 to = -1; } }
18 return it; }
19// euler(0,-1,L.begin())
20// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 4

insertMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected