Skip to content

Commit 1a201ca

Browse files
updated the size of the queue
1 parent bc2dfe5 commit 1a201ca

File tree

6 files changed

+115
-3
lines changed

6 files changed

+115
-3
lines changed

0x06-graphs/graphs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define UNEXPLORED 0
1111
#define EXPLORED 1
1212
#define BACKTRACK 2
13-
#define SIZE INT_MAX
13+
#define SIZE 65536
1414
#define LEVELBREAK -60
1515
/**
1616
* enum edge_type_e - Enumerates the different types of

0x06-graphs/tests/graphs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define UNEXPLORED 0
1111
#define EXPLORED 1
1212
#define BACKTRACK 2
13-
#define SIZE INT_MAX
13+
#define SIZE 65536
1414
#define LEVELBREAK -60
1515
/**
1616
* enum edge_type_e - Enumerates the different types of

0x06-graphs/tests/main_0.c

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ int main(void)
5757
}
5858
}
5959
}
60-
graph_display(graph);
6160
depth = breadth_first_traverse(graph, &traverse_action);
6261
printf("\nDepth: %lu\n", depth);
6362

0x06-graphs/tests/main_2.c

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Description: Traverse a graph with no vertex, and no edge */
2+
3+
#include <stdlib.h>
4+
#include <stdio.h>
5+
6+
#include "graphs.h"
7+
#include "_names.h"
8+
#include "_edges.h"
9+
10+
/**
11+
* traverse_action - Action to be executed for each visited vertex
12+
* during traversal
13+
*
14+
* @v: Pointer to the visited vertex
15+
* @depth: Depth of the vertex in graph from vertex 0
16+
*/
17+
void traverse_action(const vertex_t *v, size_t depth)
18+
{
19+
printf("(%lu) [%lu] %s\n", depth, v->index, v->content);
20+
}
21+
22+
/**
23+
* main - Entry point
24+
*
25+
* Return: EXIT_SUCCESS or EXIT_FAILURE
26+
*/
27+
int main(void)
28+
{
29+
graph_t *graph;
30+
size_t depth;
31+
32+
graph = graph_create();
33+
if (!graph)
34+
{
35+
printf("Failed to create graph\n");
36+
return (EXIT_FAILURE);
37+
}
38+
39+
depth = breadth_first_traverse(graph, &traverse_action);
40+
printf("\nDepth: %lu\n", depth);
41+
42+
graph_delete(graph);
43+
44+
return (EXIT_SUCCESS);
45+
}

0x06-graphs/tests/main_3.c

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Description: `depth_first_traverse(graph, NULL);` */
2+
3+
#include <stdlib.h>
4+
#include <stdio.h>
5+
6+
#include "graphs.h"
7+
#include "_names.h"
8+
#include "_edges.h"
9+
10+
/**
11+
* main - Entry point
12+
*
13+
* Return: EXIT_SUCCESS or EXIT_FAILURE
14+
*/
15+
int main(void)
16+
{
17+
graph_t *graph;
18+
size_t depth;
19+
20+
graph = graph_create();
21+
if (!graph)
22+
{
23+
printf("Failed to create graph\n");
24+
return (EXIT_FAILURE);
25+
}
26+
27+
depth = breadth_first_traverse(graph, NULL);
28+
printf("\nDepth: %lu\n", depth);
29+
30+
graph_delete(graph);
31+
32+
return (EXIT_SUCCESS);
33+
}

0x06-graphs/tests/main_4.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Description: `depth_first_traverse(NULL, &traverse_action);` */
2+
3+
#include <stdlib.h>
4+
#include <stdio.h>
5+
6+
#include "graphs.h"
7+
#include "_names.h"
8+
#include "_edges.h"
9+
10+
/**
11+
* traverse_action - Action to be executed for each visited vertex
12+
* during traversal
13+
*
14+
* @v: Pointer to the visited vertex
15+
* @depth: Depth of the vertex in graph from vertex 0
16+
*/
17+
void traverse_action(const vertex_t *v, size_t depth)
18+
{
19+
printf("(%lu) [%lu] %s\n", depth, v->index, v->content);
20+
}
21+
22+
/**
23+
* main - Entry point
24+
*
25+
* Return: EXIT_SUCCESS or EXIT_FAILURE
26+
*/
27+
int main(void)
28+
{
29+
size_t depth;
30+
31+
depth = breadth_first_traverse(NULL, &traverse_action);
32+
printf("\nDepth: %lu\n", depth);
33+
34+
return (EXIT_SUCCESS);
35+
}

0 commit comments

Comments
 (0)