summaryrefslogtreecommitdiff
path: root/src/03/matrix.c
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-09-27 13:11:12 -0600
committermo khan <mo.khan@gmail.com>2020-09-27 13:11:12 -0600
commitfc3968bcecc579c331ad01645def3f8e379984c4 (patch)
tree6e1b701c0b2458d5a6b1a49c2381b5e988353da1 /src/03/matrix.c
parent1fdac316bde6e192a6ebf51148af0ee66a6ae831 (diff)
docs: document each function
Diffstat (limited to 'src/03/matrix.c')
-rw-r--r--src/03/matrix.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/03/matrix.c b/src/03/matrix.c
index 9398cae..1e4d310 100644
--- a/src/03/matrix.c
+++ b/src/03/matrix.c
@@ -5,6 +5,11 @@ char labels[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
+/**
+ * Traverses a graph represented as an adjacency matrix
+ * to visit every vertex in the graph and traverse each
+ * edge in both directions only once.
+ */
void matrix_traverse(int n, int graph[n][n], int visited[n], int vertex) {
printf("->(%c)", labels[vertex]);
visited[vertex] = 1;
@@ -27,6 +32,13 @@ void matrix_traverse(int n, int graph[n][n], int visited[n], int vertex) {
}
}
+/**
+ * Prints a visual representation of an
+ * adjacency matrix to stdout out for debugging purposes.
+ *
+ * @param n The number of vertexes in the graph.
+ * @param graph The adjacency matrix that represents the graph.
+ */
void matrix_inspect(int n, int graph[n][n]) {
printf("\n");