adjacency list question
For a current project I am creating I decided the best way to implement the code would be through an adjacency list. I am just simply confused on what the structs would look like and how to create the reference. For example,
I have one struct for all the vertices and another struct for the adjacent vertices. I need to be able to travel from vertex a to the adjacent vertex b, for example, but b should be a reference to the vertex node b so that I can "jump" from the adjacent vertice chain to the vertex chain.
[Vertex] [Adjacent Vertices]
My structs are setup as follows:
So what I am wondering is do my structs look setup correctly and how would I do the jumping from an adajcency vertex to a vertex?
adj_node* path; //for the adjacency vertex chain (A->C->B->E)
node* down; //to travel down the vertex chain (A-B-C)
Why wouldn't you just have nodes, which have a char vertex and a node** next which would be a dynamic array of pointers? You would then have that node (and perhaps node, etc.) would be pointers to adjacent nodes; following a path might then look like current = current->next, or the like. You would also want int number_of_paths or something so that you know how big your next array is.