Social Network 1.0.0
The second major course output (MCO2) for CCDSALG.
Loading...
Searching...
No Matches
traversal.h File Reference

The utility functions that are used to traverse through graphs and get the list of the visited vertices in order. More...

#include <stddef.h>
#include "graph.h"

Go to the source code of this file.

Functions

void breadth_first_search (const Graph *const graph, const Vertex starting_vertex, Vertex visited_vertices[MAX_GRAPH_VERTEX_COUNT], size_t *const visited_vertex_count)
 Traverses through all of a graph’s connected vertices starting from a specific vertex.
void depth_first_search (const Graph *const graph, const Vertex starting_vertex, Vertex visited_vertices[MAX_GRAPH_VERTEX_COUNT], size_t *const visited_vertex_cnt)
 Traverses through all of a graph’s connected vertices starting from a specific vertex.

Detailed Description

The utility functions that are used to traverse through graphs and get the list of the visited vertices in order.

Author
Raphael Panaligan
Jek Degullado

Function Documentation

◆ breadth_first_search()

void breadth_first_search ( const Graph *const graph,
const Vertex starting_vertex,
Vertex visited_vertices[MAX_GRAPH_VERTEX_COUNT],
size_t *const visited_vertex_count )

Traverses through all of a graph’s connected vertices starting from a specific vertex.

This uses the breadth-first search algorithm to traverse through the graph.

Parameters
[in]graphThe graph to traverse through.
starting_vertexThe vertex to start from.
[out]visited_verticesThe vertices visited during the traversal.
[out]visited_vertex_countThe number of vertices visited during the traversal.

◆ depth_first_search()

void depth_first_search ( const Graph *const graph,
const Vertex starting_vertex,
Vertex visited_vertices[MAX_GRAPH_VERTEX_COUNT],
size_t *const visited_vertex_cnt )

Traverses through all of a graph’s connected vertices starting from a specific vertex.

This uses the depth-first search algorithm to traverse through the graph.

Parameters
[in]graphThe graph to traverse through.
starting_vertexThe vertex to start from.
[out]visited_verticesThe vertices visited during the traversal.
[out]visited_vertex_cntThe number of vertices visited during the traversal.