title: Depth First Search with Adjacency Matrix
body: <p>I am completing a class lab which takes an adjacency matrix, and determines connectivity among vertices. Although my code runs, it does not give the correct results.</p>
  
  <p>I believe there is a problem with the the second if statement in my while loop. any help is greatly appreciated. Code is below:</p>
  
  <pre><code>#include "graph.h"
  #include &lt;assert.h&gt;
  
  using namespace std;
  
  bool Graph::connected(int v,int w) {
  
      int visited[SIZE] ={0};
  
      if (v == w)         
          return adj_matrix[v][v];
  
      Queue&lt;int&gt; Q;      
      Q.Enqueue(v);      
  
      while (!Q.empty()) {
          int curr = Q.Dequeue();
  
          if (curr == w)
              return true;
  
          int z=0;         
          for (int i=0; i&lt;SIZE; i++) {      
              if (adj_matrix[curr][z]==1 &amp;&amp; visited[i]==false) {
                  Q.Enqueue(z);
                  visited[i]==true;
              }   
          }
      }
      return false;  
  }
  </code></pre>
  
  <p>This is the output I am receiving:</p>
  
  <pre><code>0 0 1 0 
  0 0 0 0 
  0 0 0 0 
  0 0 0 1 
  vertex 0 is connected to vertices: 
  vertex 1 is connected to vertices: 
  vertex 2 is connected to vertices: 
  vertex 3 is connected to vertices: 3 
  </code></pre>
  
  <p>Which is clearly missing another connection between 0 and 2 correct?</p>