initial commit
This commit is contained in:
parent
72edcbd75d
commit
32541218bc
17
graph.c
Normal file
17
graph.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void random_adjacency(const uint64_t row_length, const uint64_t column_length, uint64_t matrix[row_length][column_length]) {
|
||||
srand(time(NULL));
|
||||
|
||||
for (uint8_t row_index=0; row_index < row_length; row_index++) {
|
||||
for (uint8_t column_index=0; column_index < column_length; column_index++) {
|
||||
if(column_index == row_index) {
|
||||
matrix[row_index][column_index] = 1;
|
||||
continue;
|
||||
}
|
||||
matrix[row_index][column_index] = rand()%2;
|
||||
}
|
||||
}
|
||||
}
|
8
graph.h
Normal file
8
graph.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef GRAPH_H
|
||||
#define GRAPH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void random_adjacency(const uint64_t row_length, const uint64_t column_length, uint64_t matrix[row_length][column_length]);
|
||||
|
||||
#endif
|
14
main.c
Normal file
14
main.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "graph.h"
|
||||
#include "matrix.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
int main(void) {
|
||||
const uint8_t row_length = 5;
|
||||
const uint8_t column_length = 5;
|
||||
uint64_t matrix[row_length][column_length];
|
||||
|
||||
random_adjacency(row_length, column_length, matrix);
|
||||
|
||||
print_matrix(row_length, column_length, matrix);
|
||||
}
|
11
matrix.c
Normal file
11
matrix.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void print_matrix(const uint8_t row_length, const uint8_t column_length, const uint64_t matrix[row_length][column_length]) {
|
||||
for (uint8_t column_index=0; column_index < column_length; column_index++) {
|
||||
for (uint8_t row_index=0; row_index < row_length; row_index++) {
|
||||
printf("%lu ", matrix[row_index][column_index]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user