title: Finding bridges in graph without recursion
body: <p>I have this code to find bridges in a connected graph:</p>
  
  <pre class="lang-C prettyprint-override"><code>void dfs (int v, int p = -1) {
      used[v] = true;
      tin[v] = fup[v] = timer++;
      for (size_t i=0; i&lt;g[v].size(); ++i) {
          int to = g[v][i];
          if (to == p)  continue;
          if (used[to])
              fup[v] = min (fup[v], tin[to]);
          else {
              dfs (to, v);
              fup[v] = min (fup[v], fup[to]);
              if (fup[to] &gt; tin[v])
                  printf("%d %d", v, to);
          }
      }
  }
  </code></pre>
  
  <p>How to rewrite it without using recursion? I know, it's possible to do it and I should use stack, but this line must be executed after recursive call of dfs() and I can't achieve with a stack:</p>
  
  <pre><code>fup[v] = min(fup[v], fup[to])
  </code></pre>
  
  <p>So, how to rewrite my algorithm iteratively?</p>