-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
92 lines (86 loc) · 1.76 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include<stdio.h>
#include<stdlib.h>
#include "search.h"
#include "stats.h"
int compare(char* a, char* b);
int main(int argc, char** argv)
{
if (argc == 1) {
printf("error!\n");
return 0;
}
char help[3] = "-h";
char graph[3] = "-g";
char stats[3] = "-s";
char paint[3] = "-j";
char search[4] = "-sp";
char s_edges[6] = "edges";
char s_vertices[9] = "vertices";
char s_freeman[8] = "freeman";
char s_closeness[10] = "closeness";
if (compare(argv[2], help)) {
printf("-g FILE_PATH -s include edges, vertices, freeman, closeness.\n");
printf("-g FILE_PATH -sp include DFS, BFS, Dijkstra.\n");
return 0;
}
else if (compare(argv[2], paint)) {
printf(" \\/ \n");
printf(" || \n");
printf(" _/\\_ \n");
printf("( @ @ )\n");
printf(" \\_-__/ \n");
return 0;
}
else if (compare(argv[4], stats)) {
if (compare(argv[5], s_edges)) {
printf("%d", numberOfEdges(argv[2]));
return 0;
}
else if (compare(argv[5], s_vertices)) {
printf("%d", numberOfVertices(argv[2]));
return 0;
}
else if (compare(argv[5], s_freeman)) {
//printf("%d", freemanNetworkCentrality(argv[2]));
return 0;
}
}
else if (compare(argv[4], search)) {
char* path = shortestPath(atoi(argv[7]), atoi(argv[9]), argv[5], argv[3]);
puts(path);
}
return 0;
}
int compare(char* a, char* b)
{
int length_a = 0;
int length_b = 0;
int i = 0;
while(a[i] != '\0') {
length_a++;
i++;
}
i = 0;
while(b[i] != '\0') {
length_b++;
i++;
}
i = 0;
if(length_a == length_b) {
while(a[i] != '\0' && b[i] != '\0') {
if(a[i] == b[i]) {
i++;
continue;
}
else {
return 0;
}
}
if(i == length_a) {
return 1;
}
}
else {
return 0;
}
}