-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
90 lines (79 loc) · 2.24 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
81
82
83
84
85
86
87
88
89
90
// Copyright 2021 András Mihálykó MIT License
/*
Driver program for M-component hypergraph creation,
finding transversal vertices of the MCT sets and
adding minimal number of edges so that G becomes M-connected.
If G is (k,l)-tight, this latter adds the minimal number of edges to
make G (k,l)-redundant.
This is an accompanying program to the PhD dissertation titled
"Augmentation problems in count matroids and globally rigid graphs"
*/
#include <iostream>
#include "graph.h"
#include "M-comp.h"
#include "redund.h"
int main(int argc, char *argv[]) {
unsigned int k = 2;
int ell = 3;
try {
if (argc == 3) {
if (atoi(argv[1]) > 0) {
k = atoi(argv[1]);
ell = atoi(argv[2]);
} else {
std::cerr << "k must be positive" << std::endl;
throw 1;
}
}
} catch (int e) {
std::cerr <<"Error code " << e << std::endl;
return e;
}
SimpleGraph G;
try {
G.readFromInput();
} catch (int e) {
std::cerr <<"Error code " << e << std::endl;
return e;
}
M_compHyperGraph HG;
try {
HG = M_compHyperGraph(G.getNumberOfNodes(), k, ell);
} catch (int e) {
std::cerr <<"Error code " << e << std::endl;
return e;
}
HG.MakeMCompHypergraph(G);
std::cout << " " << std::endl;
HG.print();
RedundHyperGraph R(HG);
std::vector<std::shared_ptr<Vertex> > P;
bool exceptionCaught = true;
try {
P = R.findTransversal();
exceptionCaught = false;
} catch (int e) {
std::cerr <<"Error code " << e << std::endl;
}
if (!exceptionCaught) {
std::cout << "Transversal of the MCT sets of the M-comp hypergraph" << std::endl;
for (std::shared_ptr<Vertex> v : P) {
v->print();
std::cout << " ";
}
std::cout << std::endl;
}
std::cout << "Optimal redund augmentation edges: " << std::endl;
std::vector<Edge> F;
try {
F = R.toRedund();
} catch (int e) {
std::cerr <<"Error code " << e << std::endl;
if (e == 31) {
return e;
}
}
for (Edge& f : F) {
f.print();
}
}