Graph-DFS
Learn Theory - DFS DFS Implementation using a recursive function /*******************************************************************************/ #include <stdio.h> #define MAX_VERTICES 10 // Function to perform Depth-First Search (DFS) void dfs(int vertex, int visited[MAX_VERTICES], int adjacencyMatrix[MAX_VERTICES][MAX_VERTICES], int numVertices) { printf("V%d ", vertex ); // Assuming vertex labels are 'V0', 'V1', 'V2', ... // Mark the current vertex as visited visited[vertex] = 1; // Recursively visit all unvisited neighbors for (int i = 0; i < numVertices; i++) { if (adjacencyMatrix[vertex][i] == 1 && !visited[i]) { dfs(i, visited, adjacencyMatrix, numVertices); } } } int main() { int numVertices, i, j; printf("Enter the number of vertices (max %d): ", MAX_VE...