Untitled
Graph_t* readgraph(FILE *in){ int dest, w, k; double weight; char buf[MAX_BUF]; int count = -1; int offset; fscanf(in, "%d %d", &w, &k); Graph_t* graf = initgraph(k, w); while (fgets(buf, MAX_BUF, in) != NULL){ char *data = buf; while (sscanf(data, "%d :%lf%n", &dest, &weight, &offset) == 2) { Node_t* node = malloc(sizeof(*node)); node->dest = dest; node->weight = weight; node->next = graf->adjlist[count]; graf->adjlist[count] = node; data += offset; } count++; } return graf; }