Graph newGraph(int nV)
{
assert(nV >= 0);
int i, j;
int **e = malloc(nV * sizeof(int *));
assert(e != NULL);
for (i = 0; i < nV; i++) {
e[i] = malloc(nV * sizeof(int));
assert(e[i] != NULL);
for (j = 0; j < nV; j++)
e[i][j] = 0;
}
Graph g = malloc(sizeof(GraphRep));
assert(g != NULL);
g->nV = nV; g->nE = 0; g->edges = e;
return g;
}
|