-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (41 loc) · 1.08 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
#include <iostream>
#include "DiGraph.h"
#include "OpenCVGraphVisualizer.h"
#include <ctime>
#define ANZAHL 10
#define AUFLX 1500
#define AUFLY 960
#define BEREICHX (AUFLX - 199)
#define BEREICHY (AUFLY - 199)
std::string ranStr(int size) {
int i;
std::string str;
for (i = 0; i < size; ++i) {
str.push_back((char)((rand() % 26) + 'A'));
}
return str;
}
int main() {
std::srand( static_cast<unsigned int>(std::time(NULL)));
std::string keys[ANZAHL];
int posx[ANZAHL];
int posy[ANZAHL];
DiGraph diGraph;
Node node[ANZAHL];
for (int i = 0; i < ANZAHL; i++) {
keys[i] = ranStr(3);
posx[i] = (std::rand() % BEREICHX) + 100;
posy[i] = (std::rand() % BEREICHY) + 100;
node[i].setKey(keys[i]);
node[i].setPositionX(posx[i]);
node[i].setPositionY(posy[i]);
diGraph.addNode(&node[i]);
if (i > 0) {
diGraph.addEdge(keys[i - 1], keys[i], std::rand() % 10);
}
}
OpenCVGraphVisualizer ogv(AUFLX,AUFLY);
ogv.render(diGraph);
ogv.show();
return 0;
}