-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEULER.cc
36 lines (28 loc) · 830 Bytes
/
EULER.cc
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
#ifndef EULER_CC_
#define EULER_CC_
#include <iostream>
#include "SEARCH.cc"
using namespace std;
// Программа 18.5. Двухпроходный эйлеров цикл
template <class Graph>
class EULER : public SEARCH<Graph> {
void searchC(Edge e) {
int v = e.v, w = e.w;
this->ord[w] = this->cnt++;
cout << "-" << w;
typename Graph::adjIterator A(this->G, w);
for (int t = A.beg(); !A.end(); t = A.nxt()) {
if (this->ord[t] == -1) searchC(Edge(w, t));
else if (this->ord[t] < this->ord[v]) {
cout << "-" << t << "-" << w;
}
}
if (v != w) cout << "-" << v;
else cout << endl;
}
public:
EULER(const Graph &G) : SEARCH<Graph>(G) {
this->search();
}
};
#endif