#include #include #include #include #include "matrix.h" void random_adjacency(const uint64_t vertex_count, uint64_t matrix[vertex_count][vertex_count]) { srand(time(NULL)); for (uint64_t row_index = 0; row_index < vertex_count; row_index++) { for (uint64_t column_index = 0; column_index < vertex_count; column_index++) { if (column_index == row_index) { matrix[row_index][column_index] = 0; continue; } matrix[row_index][column_index] = rand() % 2; } } } void calculate_distance_matrix(const uint64_t vertex_count, const uint64_t adjacency_matrix[vertex_count][vertex_count], uint64_t distance_matrix[vertex_count][vertex_count]) { uint64_t power_matrix[vertex_count][vertex_count]; uint64_t temp_power_matrix[vertex_count][vertex_count]; copy(vertex_count, vertex_count, adjacency_matrix, power_matrix); for (uint64_t row_index = 0; row_index < vertex_count; row_index++) { for (uint64_t column_index = 0; column_index < vertex_count; column_index++) { if (row_index == column_index) { distance_matrix[row_index][column_index] = 0; } else if (adjacency_matrix[row_index][column_index] == 1) { distance_matrix[row_index][column_index] = 1; } else { distance_matrix[row_index][column_index] = UINT64_MAX; } } } for(uint64_t k = 2; k <= vertex_count; k++) { copy(vertex_count, vertex_count, power_matrix, temp_power_matrix); matrix_multiply_basic(vertex_count, vertex_count, adjacency_matrix, vertex_count, vertex_count, temp_power_matrix, power_matrix); for (uint64_t row_index = 0; row_index < vertex_count; row_index++) { for (uint64_t column_index = 0; column_index < vertex_count; column_index++) { if (power_matrix[row_index][column_index] != 0 && distance_matrix[row_index][column_index] == UINT64_MAX) { distance_matrix[row_index][column_index] = k; } } } } } void calculate_eccentricities(const uint64_t vertex_count, const uint64_t output_arraay[vertex_count]) { }