Hello!
I was trying to work towards the adjacent list. I am using the function to make adjacent list but am not able to pass my data to it.
Can someone help me with this?
the code is
Code:
```struct adj_node  /*the NODE which forms the part of the adjacency list; look at figure [B]*/
{
char vertex_val;
};

struct node /*the NODE which forms the part of the Graph; look at figure [A]*/
{
char vertex_val;
struct node *next;  /*black pointer*/
};

struct node *graph;
struct node *cur_vertex, *aux_ptr;

{

/*Step-1 of the algorithm is expected from you or refer linked LISTS*/
/*Step-1 gives you a list, being pointed by 'graph' */

cur_vertex = graph;   /*first node of the graph in consideration*/
/*Step-2 starts here*/
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*/
while (aux_ptr != NULL)
{
printf("Is there any edge between %c and %c ",aux_ptr->vertex_val, cur_vertex->vertex_val);
scanf("%d", &edge);/*step-2: part-A*/
if( edge == 1) /*step-2: part - B*/
{
}
else
{
new -> vertex_val = aux_ptr ->vertex_val;
}
aux_ptr = aux_ptr ->next;
}
cur_vertex = cur_vertex ->next;
}
}```
I want to pass the data to the above function for making the LL but i dont know how it shd be passed.
I am reading the data from the file as
Code:
```FILE *fp;
int i, count = 0;
char c;

fp = fopen("data","r");    // reading the Edge file
while((c=getc(fp))!=EOF)
{
if(c=='\n')
count++;
}
printf("\tThe total number of entries: %d\n", count);
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(fp,"%d  %d %f \n", &C1[i], &C2[i], &C3[i]);
//   printf("%d  %d %f  %c\n", C1[i], C2[i], pC3[i], C4[i]);

}``` 2. Is that all of the code? Sure doesn't seem like it. Most of your used variables are undeclared. And passing the root node to your function should be enough, checking for node->next != NULL

Code:
```while(node){
...
node = node->next
}``` 3. I am reading my file in 3 columns. C1, C2, C3.
I dont know how to put that in LL.
C1 = Node1
C2 = Node2
C3 = Value. 4. it didnt work out for me
I couldn't pass the input file to the above mentioned structure.
Am I reading my data in some wrong format ???? 5. This is rather confusing as we don't have the assignment you were given for this (nor figures A and b), and there is a bit more going on than just linked lists. Looks like what you need to do is populate the graph variable before calling the function. Popular pages Recent additions 