Download benchmarks/Algorithms/DFS_adjacency_list/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 814 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/DFS_adjacency_list/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/DFS_adjacency_list/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/DFS_adjacency_list/solution.c
814 Bytes
| /* | |
| * Recursive depth-first search over a linked-list adjacency graph. | |
| * | |
| * Vertices are numbered from 0 through vertex_count - 1. For every vertex | |
| * u, adjacency[u] is the head of a linked list whose data fields contain u's | |
| * neighbor vertex numbers. The graph storage is read-only; visited is | |
| * supplied by the caller and is updated in place. | |
| */ | |
| void dfs_adjacency_list(struct list **adjacency, int vertex_count, | |
| int *visited, int vertex) | |
| { | |
| visited[vertex] = 1; | |
| struct list *edge = adjacency[vertex]; | |
| while (edge != (struct list *)0) { | |
| int neighbor = edge->data; | |
| if (visited[neighbor] == 0) { | |
| dfs_adjacency_list(adjacency, vertex_count, visited, neighbor); | |
| } else { | |
| } | |
| edge = edge->next; | |
| } | |
| } | |