code direct graph traverser with given starting node and a 2d array which represents the graph thus test cases
1, [ [ 1, 2 ], [ 1, 3 ], [ 3, 4 ] ]
3, [ [ 1, 2 ], [ 1, 3 ], [ 3, 4 ] ]
1, [ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 4, 5 ], [ 5, 1 ], [ 5, 7 ] ]
5, [ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 4, 5 ], [ 5, 1 ], [ 5, 7 ] ]