-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
72 lines (65 loc) · 2.23 KB
/
main.c
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
// other libraries
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "src/consts_n_structures.h"
#include "src/graph_create.h"
#include "src/vec_math_lib.h"
#include "src/X_routines.h"
#include "src/graph_draw.h"
int main() {
int n1 = 2, n2 = 1, n3 = 2, n4 = 5;
srand(n1 * 1000 + n2 * 100 + n3 * 10 + n4);
int n = 10 + n3;
double c = 1.0 - n3 * 0.02 - n4 * 0.005 - 0.25;
double **service_mat;
service_mat = randm(n, n);
int **rel_mat;
rel_mat = mat_create(n, n);
point_t *graph;
XEvent event;
KeySym key;
char text[255]; //keyboard buffer
init_x();//window created
while (1) {
XNextEvent(dis, &event);
switch (event.type) {
case Expose:
if (event.xexpose.count == 0) redraw_x();
break;
case KeyPress:
if (XLookupString(&event.xkey, text, 255, &key, 0) == 1) {
int oriented = 42;
switch (text[0]) {
case 'q':
free_mat(service_mat, n);
free_mat(rel_mat, n);
free(graph);
close_x();
return 0;
break;
case 'o':
oriented = 1;
printf("drawing oriented relation matrix: \n");
break;
case 'u':
oriented = 0;
printf("drawing unoriented relation matrix: \n");
break;
default:
redraw_x();
oriented = 42;
}
if (oriented != 42) {
redraw_x();
rel_mat = mulmr(c, service_mat, rel_mat, n, n, oriented);
print_mat(rel_mat, n, n);
graph = tri_graph_create(graph, n);
draw_graph(graph, rel_mat, n, oriented);
draw_graph_vertices(graph, n);
}
break;
}
}
}
}