-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.c
47 lines (41 loc) · 1.37 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
// Do not change this file, except while you are debugging.
// The TAs will use the original main for grading. You might
// want to pull down the original starter code and just copy in your
// BFS.c, DFS.c, Queue.c and Queue.h files and build it. This would
// assure that you haven't broken anything by changing other files.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MUCSGraph.h"
#include "BFS.h"
#include "DFS.h"
int main(void)
{
/******************************************************/
/* Set things up by loading the graph and printing it */
int countVertices, countEdges;
int isDirected = GetDirected();
int startNode = GetStartNode();
GetCounts(&countVertices,&countEdges);
Vertex vertices[countVertices];
Edge edges[countEdges];
memset(vertices,0,sizeof(vertices));
memset(edges,0,sizeof(edges));
GetEdges(edges,countEdges);
BuildAdjacency(vertices,edges,countVertices,countEdges);
printf("\n\n****Graph:\n");
if (isDirected)
{
printf("DIRECTED\n");
}
else
{
printf("UNDIRECTED\n");
}
printf("Start node: %d\n",startNode);
PrintVertices(vertices,countVertices);
printf("\n");
/******************************************************/
PrintBFS(vertices,countVertices,edges,countEdges,startNode);
PrintDFS(vertices,countVertices,edges,countEdges);
}