-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
80 lines (63 loc) · 1.78 KB
/
main.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include "Graph.h"
#include "CoordinatesBuilder.h"
#include "check_drawing.h"
using namespace std;
bool test_non_biconnected(vector<Graph> &components) {
bool result;
Embedding embedding;
for(Graph &comp : components) {
PlanarityTest tester(comp);
tie(result, embedding) = tester.test();
if(!result) return false;
}
return true;
}
pair<bool,vector<pair<int,int>>> get_coordinates(Graph &G) {
PlanarityTest tester(G);
bool result;
Embedding embedding;
tie(result, embedding) = tester.test();
if(result) {
CoordinatesBuilder creator(embedding);
return {result, creator.get_coordinates()};
} else {
return {result, vector<pair<int,int>>()};
}
}
int main(int argc, char **argv) {
char* input_path = argv[1];
char* output_path = argv[2];
ifstream in(input_path);
cin.rdbuf(in.rdbuf());
ofstream out(output_path);
cout.rdbuf(out.rdbuf());
int n, m;
cin >> n >> m;
Graph G(n);
for(int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--; b--;
G.add_edge(a, b);
}
vector<Graph> components = G.get_biconnected_components();
if(components.size() == 1) {
cout << 1 << endl;
bool planar;
vector<pair<int,int>> coordinates;
tie(planar, coordinates) = get_coordinates(G);
cout << planar << endl;
if(planar) {
cout << check_drawing(G, coordinates) << endl;
for(int i = 0; i < n; i++) {
cout << coordinates[i].first << " " << coordinates[i].second << endl;
}
}
} else {
cout << 0 << endl;
bool planar = test_non_biconnected(components);
cout << planar << endl;
}
return 0;
}