-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestGraph.cpp
More file actions
93 lines (76 loc) · 2.08 KB
/
TestGraph.cpp
File metadata and controls
93 lines (76 loc) · 2.08 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
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
91
92
93
#include <iostream>
#include <unordered_map>
//#include "FunctGroup.cpp"
#include "ReadCSV.cpp"
int main (int argc, char * argv[]) {
Graph<FunctGroup> g;
const int size = 3;
FunctGroup * nodes[size] = {
new FunctGroup("H", false, "12"),
new FunctGroup("O", false, "1"),
new FunctGroup("O", false, "2")
};
for (int i = 0; i < size; i++) {
g.add_node(nodes[i]);
}
g.add_edge(nodes[0], nodes[1], 1);
g.add_edge(nodes[1], nodes[0], 1);
g.add_edge(nodes[2], nodes[0], 2);
g.add_edge(nodes[2], nodes[0], 1);
cout << g.to_string();
/*
unordered_map<string, int> m = {
{"one", 1},
{"two", 2},
{"three", 3}
};
*/
unordered_map<FunctGroup, int> m = {
{*nodes[0], 0},
{*nodes[1], 1},
{*nodes[2], 2}
};
for (const auto& p: m) {
cout << "Key:[" << p.first << "] Value[" << p.second << "]" << endl;
}
//if we have some positional commandline args...
if (argc > 1) {
//...use the first one as the filename for the table of Joback contributions
string filename = argv[1];
auto * table = read_joback(filename);
/*
//print out the table
for (auto row: *table) {
cout << "Key:[" << *row.first
<< "] Values:" << endl;
for (auto contrib: *row.second) {
cout << " Key:[" << contrib.first
<< "] Value[" << contrib.second << "]" << endl;
}
}
*/
//clean up memory
for (auto row: *table) {
//cout << *row.first << endl;
//delete row.first;
delete row.second;
}
delete table;
}
if (argc > 2) {
string filename = argv[2];
Graph<FunctGroup> * graph = read_graph(filename);
cout << "Initial Graph:" << endl;
cout << graph->to_string();
cout << "=========================================" << endl;
find_cycles(graph);
cout << "=========================================" << endl
<< "Final Graph:" << endl;
cout << graph->to_string();
}
//clean up all allocated memory
//FunctGroups from nodes
for (int i = 0; i < size; i++) {
delete nodes[i];
}
}