[prev] [index] [next]

Array-of-edges Representation (cont)

Implementation of graph initialisation:

Graph newGraph(int nV)
{
   assert(nV >= 0);
   int n = BigEnough;
   Edge *e = malloc(n*sizeof(Edge));
   assert(e != NULL);
   Graph g = malloc(sizeof(GraphRep));
   assert(g != NULL);
   g->nV = nV;  g->nE = 0;
   g->n = n;  g->edges = e;
   return g;
}

How large should n be? ... No more than (V2-V)/2