title: Problems initializing a Graph based on Array with adjacency lists in C
body: <p>I've played with Graphs before and I managed it alright with some help from StackOverflow but I never used a structure like the one below. I can't seem to understand what I'm doing wrong here...</p>
  
  <pre><code>#include "stdio.h"
  #include "stdlib.h"
  
  #define MaxV 100
  #define MaxE 50
  
  typedef struct edge {
      int dest;
      int cost;
  
      struct edge *next;
  } Edge, *Graph[MaxV];
  
  Graph *initGraph() {    
      Graph *g = (Graph*)malloc(sizeof(Edge) * MaxV);
  
      for(int i = 0; i &lt; MaxV; i++)
          (*g[i])-&gt;next = NULL;
  
      return g;
  }
  
  int main(void) {
      Graph *g = initGraph();
  
      for(int i = 0; i &lt; MaxV; i++) {
          if((*g[i])-&gt;next == NULL) printf("[%02d] NULL\n", i);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I get a segmentation fault on the first iteration of <code>(*g[i])-&gt;next = NULL;</code> and I can't understand why. I've tried countless things but I can't seem to manage the Graph initialization with such structure. Also, is the way I'm declaring and returning a pointer to a Graph done the right way for this structure?</p>
  
  <p>Am I complicating things with lots of pointers in the init function or what?</p>
  
  <p><strong>P.S: Please do not suggest different structure definitions, I cannot changing anything in the one above. That's the real issue. I know how to work with Graphs rolling my own structure, but I need to use the one above.</strong></p>