
#include <LEDA/graph/graph.h>

using namespace leda;


void dfs(const graph& G, node v, node_array<int>& dfsnum, 
                                 node_array<int>& compnum,
                                 int& count1,
                                 int& count2)
{ 
  dfsnum[v] = ++count1;

  edge e;
  forall_out_edges(e,v) 
  { node w = G.target(e);
    if (dfsnum[w] == 0) { 
      // w not visited
      dfs(G,w,dfsnum,compnum,count1,count2);
    }
  }

  compnum[v] = ++count2;
} 


int main() 
{
   int n = 100;
   int m = 1000;

   graph G;

   random_graph(G,n,m);

   node_array<int> dfsnum(G,0);
   node_array<int> compnum(G,0);
   
   list<edge> T;

   int count1 = 0;
   int count2 = 0;

   node v;
   forall_nodes(v,G) {
     if (dfsnum[v] == 0) dfs(G,v,dfsnum,compnum,count1,count2);
   }

   forall_nodes(v,G) {
     cout << dfsnum[v] << "  " << compnum[v] << endl;
   }

}

