What is a good way to define this graph data structure:
typedef struct
{
unsigned short isExists : 1;
WEIGHT_TYPE weight;
} Weight;
typedef struct
{
Weight adjacencyMatrix[VERTICES_NUM][VERTICES_NUM];
VERTEX_TYPE vertices[VERTICES_NUM];
} Graph;
using a value for VERTICES_NUM defined at compile time?
I am looking for a better solution than defining VERTICES_NUM before including the .h file that contains the above, and I do not want to use dynamic allocation.
I would first approach the problem with a macro that will define the types for you.
Now, a user could do something like:
And in their code, they would use the data structure like this: