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.Code:[Vertex] [Adjacent Vertices] A C,B,E B C C A,B,E D E E A,C A->C->B->E | B->C | C->A->B->E ...etc...
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?Code:struct adj_node { char vertex; adj_node* path; //for the adjacency vertex chain (A->C->B->E) }; struct node { char vertex; adj_node* next; node* down; //to travel down the vertex chain (A-B-C) };



LinkBack URL
About LinkBacks


