Download benchmarks/Algorithms/Floyd_adjacency_matrix_ptr/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 886 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/Floyd_adjacency_matrix_ptr/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/Floyd_adjacency_matrix_ptr/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/Floyd_adjacency_matrix_ptr/solution.c
886 Bytes
| int *graph_matrix_ptr_row(int **dist, int index) | |
| ; | |
| void floyd_adjacency_matrix_ptr(int n, int **dist) | |
| { | |
| int k, i, j; | |
| for (k = 0; k < n; ++k) { | |
| for (i = 0; i < n; ++i) { | |
| for (j = 0; j < n; ++j) { | |
| int *row_k; | |
| int *row_i; | |
| int dkj; | |
| int dik; | |
| int dij; | |
| row_k = graph_matrix_ptr_row(dist, k); | |
| dkj = row_k[j]; | |
| row_i = graph_matrix_ptr_row(dist, i); | |
| dik = row_i[k]; | |
| row_i = graph_matrix_ptr_row(dist, i); | |
| dij = row_i[j]; | |
| if (dik < INF && dkj < INF && dik + dkj < dij) { | |
| row_i = graph_matrix_ptr_row(dist, i); | |
| row_i[j] = dik + dkj; | |
| } | |
| } | |
| } | |
| } | |
| } | |