I have a project in C that requires me to manipulate an undirected graph. My main question is about the structures that I will be using. So far this is what I’ve got from my teacher’s explanations:
struct Node {
char name[MAX_CHAR]; // stores the node name
struct Edge *connections; // stores all of the edges connected to said node??
};
struct Edge {
struct Node destination; // stores the destination node??
int days; // edge weight
};
struct Graph {
struct Node *nodes; // stores all of the nodes on the graph
int num_nodes; // ammount of nodes on the graph
};
I am not very certain of what ‘struct Edge *connections’ and ‘struct Node destination;’ do and how I’m going to implement them on a function like create_graph or add_edge. Is there a better way to work with undirected graphs?
I just want to make sure I start with the right foot on this project and not struggle afterwards with the structs I implemented
I’ve seen some youtube videos about it and some forums, but they are mainly doing directed graphs and working with linked lists from what i understand