File tree 6 files changed +115
-3
lines changed
6 files changed +115
-3
lines changed Original file line number Diff line number Diff line change 10
10
#define UNEXPLORED 0
11
11
#define EXPLORED 1
12
12
#define BACKTRACK 2
13
- #define SIZE INT_MAX
13
+ #define SIZE 65536
14
14
#define LEVELBREAK -60
15
15
/**
16
16
* enum edge_type_e - Enumerates the different types of
Original file line number Diff line number Diff line change 10
10
#define UNEXPLORED 0
11
11
#define EXPLORED 1
12
12
#define BACKTRACK 2
13
- #define SIZE INT_MAX
13
+ #define SIZE 65536
14
14
#define LEVELBREAK -60
15
15
/**
16
16
* enum edge_type_e - Enumerates the different types of
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ int main(void)
57
57
}
58
58
}
59
59
}
60
- graph_display (graph );
61
60
depth = breadth_first_traverse (graph , & traverse_action );
62
61
printf ("\nDepth: %lu\n" , depth );
63
62
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments