
Untitled
By: a guest on
May 10th, 2012 | syntax:
C | size: 0.50 KB | hits: 17 | expires: Never
node* it = graph->nodes;
for (i = 0; i < numNodes; i++) {
numEdges = 0;
it->edges = malloc(numNodes * sizeof(struct Edge));
for (j = 0; j < numNodes; j++) {
fscanf(ifp, "%d", &weight);
if (weight != 0) {
it->edges[numEdges].weight = weight;
it->edges[numEdges].source = &graph->nodes[i];
it->edges[numEdges].destination = &graph->nodes[j];
numEdges++;
}
}
if (numEdges <= numNodes) {
it->edges = realloc(it->edges, numEdges * sizeof(struct Edge));
}
it++;