Hello everybody,

It been a while now that I am working with Linked lists.

But still get stuck very easily.

I was wondering if some1 can comment on the following code.

I had put some part of the code before too......

I am trying to make aadjacency listfrom my input data.I am not able to compile it yet....

I have already spent a lot of time on it.Your help is appreciated.

Thanks..

Code:#include <stdio.h> // I/O functions #include <stdlib.h> // malloc, realloc... #include <string.h> // string functions int edge, *pC1,*pC2; float *pC3; struct adj_node /*the NODE which forms the part of the adjacency list; */ { char vertex_val; struct adj_node *adj_next; }; struct node /*the NODE which forms the part of the Graph; */ { int *vertex_val; int *vertex_val1; float* prob; struct adj_node *down; struct node *next; }; struct node *graph; struct node *cur_vertex, *aux_ptr; void LinkListrepresentation(graph ) { struct adj_node *adj_cur, *new; cur_vertex = graph; /*first node of the graph in consideration*/ while ( cur_vertex != NULL) { aux_ptr = graph; /*an auxiliary pointer to the graph*/ adj_cur = NULL; /*an auxiliary pointer to keep track of the adjacency lists*/ cur_vertex->down = adj_cur; while (aux_ptr != NULL) { *aux_ptr->prob == edge; if( edge != 0) if( adj_cur == NULL) { adj_cur = (struct adj_node*)malloc(sizeof(adj_node)); adj_cur ->vertex_val = *aux_ptr->vertex_val; adj_cur -> adj_next = NULL; } else { new = (struct adj_node *)malloc(sizeof(adj_node)); new -> vertex_val = *aux_ptr ->vertex_val; adj_cur ->adj_next = new; adj_cur = new; adj_cur ->adj_next = NULL; } aux_ptr = aux_ptr ->next; } cur_vertex = cur_vertex ->next; } printf("%d value\n", *cur_vertex); } int main () { int *c1; // reading first column int *c2; //reading second column float *c3; // reading third column FILE *fp2; int i; int edges = 0; char c; fp2 = fopen("data.txt","r"); // Reading the Edge file while((c=getc(fp2))!=EOF) { if(c=='\n') edges = edges + 1; } printf("\tThe total number of edges: %d\n", edges); // number of edges in the network c1 = (int*) calloc(edges, sizeof(int)); c2 = (int*) calloc(edges, sizeof(int)); c3 = (float*) calloc(edges, sizeof(float)); rewind(fp2); for (i=0;i<edges;i++) { fscanf(fp2,"%d %d %f \n", &c1[i], &c2[i], &c3[i]); } struct node * graph, * head; head = NULL; for(i=0;i<edges;i++) { graph = (struct node*)malloc(sizeof(struct node)); graph->vertex_val = &c1[i]; graph->vertex_val1 = &c2[i]; graph->prob = &c3[i]; graph->next = head; head = graph; } graph = head; LinkListrepresentation(graph ); return 0; }