-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheulerianpath.cpp
More file actions
62 lines (50 loc) · 1 KB
/
Copy patheulerianpath.cpp
File metadata and controls
62 lines (50 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
typedef long long ll;
typedef long double ld;
using namespace std;
// N >= num vertices
template<int N>
struct EulerianPath {
// graph must be UNDIRECTED and CONNECTED
// returns eulerian cycle (if it exists)
// or eulerian path (if it exists)
// or empty list
// O(n) time
/* Psuedocode:
stack St
put the start vertex in St
until St is empty
let V be the vertex on top
if deg(V) == 0
add V to the answer
remove V from the top of St
else
find any edge (V, Y)
remove this edge from the graph
push Y to the top of St
*/
private:
struct edge {
int to, on = 1;
}
vector<edge> edges;
vector<int> g[N];
public:
// a != b
void addEdge(int a, int b) {
}
vector<int> getPath() {
}
}
int main() {
return 0;
}