title: What is the difference between the following two code snippets?
body: <p>DFS 1:</p>
  <pre><code>bool dfs(int source, int color, int dist) {
      vis[source] = true;
      if (source == dist)
          return true;
      for (auto x : adj[source]) {
  
          int new_node = x.first;
          if (!vis[new_node]) {
              int new_color = x.second;
              if (new_color == color)
                  return dfs(new_node, new_color, dist);
                     
          }
  
      }
      return false;
  }
  </code></pre>
  <p>DFS 2:</p>
  <pre><code>bool dfs(int source, int color, int dist) {
      vis[source] = true;
      if (source == dist)
          return true;
      for (auto x : adj[source]) {
  
          int new_node = x.first;
          if (!vis[new_node]) {
              int new_color = x.second;
              if (new_color == color)
                  if (dfs(new_node, new_color, dist))
                         return true;
                     
          }
  
      }
      return false;
  }
  </code></pre>
  <p>The line that confuses me</p>
  <p><code>return dfs(new_node, new_color, dist);</code></p>
  <p>and</p>
  <pre><code>if (dfs(new_node, new_color, dist))
          return true;
  </code></pre>
  <p>What this code is doing check if there's a path between nodes <code>source</code> and <code>dist</code> such that all the edges of the path have the same color. The second one works fine, but the first one doesn't work. Is there a difference between them?</p>