src/com/michaelho/GraphAlgorithms/GR1.java
/**
         * Traverse through the graph using DFS method.
         * Runtime: O(V+E)
         *
         * @param graph The input graph.
         *
         * @return The values of vertices in the graph output in DFS order.
         * */
Traverse through the graph using DFS method.

@param graph The input graph.

@return The values of vertices in the graph output in DFS order.
Traverse through the graph using DFS method . @param graph The input graph . @return The values of vertices in the graph output in DFS order .
int[] traverse(Graph graph) {
            boolean[] visited = new boolean[graph.V];
            int v = graph.getEdgesList().get(0).src.val;
            List<Integer> list = new ArrayList<>();
            DFSHelper(graph, list, v, visited);
            return list.stream().mapToInt(Integer::intValue).toArray();
        }
int [ ] traverse ( Graph graph ) { boolean [ ] visited = new boolean [ graph . V ] ; int v = graph . getEdgesList ( ) . get ( 0 ) . src . val ; List < Integer > list = new ArrayList < > ( ) ; DFSHelper ( graph , list , v , visited ) ; return list . stream ( ) . mapToInt ( Integer :: intValue ) . toArray ( ) ; }
Traverse through the graph using DFS method.
Traverse through the graph using DFS method .