title: Creating an adjacency List for DFS
body: <p>I'm having trouble creating a Depth First Search for my program. So far I have a class of edges and a class of regions. I want to store all the connected edges inside one node of my region. I can tell if something is connected by the getKey() function I have already implemented. If two edges have the same key, then they are connected. For the next region, I want to store another set of connected edges inside that region, etc etc. However, I am not fully understanding DFS and I'm having some trouble implementing it. I'm not sure when/where to call DFS again. Any help would be appreciated!</p>
  
  <pre><code>class edge
  { 
    private:
    int source, destination, length;
    int key;
    edge *next;
    public:
    getKey(){ return key; } 
  }
  
  class region
  {
     edge *data;
     edge *next;
     region() { data = new edge(); next = NULL; }
  
  };
  
  void runDFS(int i, edge **edge, int a)
  {
    region *head = new region();
    aa[i]-&gt;visited == true;//mark the first vertex as true
    for(int v = 0; v &lt; a; v++)
    {
      if(tem-&gt;edge[i].getKey() == tem-&gt;edge[v].getKey()) //if the edges of the vertex have the same root
      {
          if(head-&gt;data == NULL)
          {
            head-&gt;data = aa[i];
            head-&gt;data-&gt;next == NULL;
          } //create an edge
          if(head-&gt;data)
          {
            head-&gt;data-&gt;next = aa[i];
            head-&gt;data-&gt;next-&gt;next == NULL;
          }//if there is already a node connected to ti
      }
      if(aa[v]-&gt;visited == false)
        runDFS(v, edge, a); //call the DFS again
    } //for loop
   }
  </code></pre>