Driver code
var N = 4 ; var adj = [ ] ; for ( var i = 0 ; i <= N + 1 ; i ++ ) adj . push ( new Array ( ) ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 2 , 3 ) ; addEdge ( adj , 3 , 4 ) ; DFS ( adj , N ) ;