src/com/michaelho/GraphAlgorithms/GR1.java
/**
         * The function to get the reversed graph.
         *
         * @param graph The graph to be reversed.
         *
         * @return A reversed graph of the input graph.
         * */
The function to get the reversed graph.
@param graph The graph to be reversed.

@return A reversed graph of the input graph.
The function to get the reversed graph . @param graph The graph to be reversed . @return A reversed graph of the input graph .
private Graph reverseGraph(Graph graph) {
            Graph g = new Graph(graph.V, graph.E);
            for (int v = 0; v < graph.V; v++) {
                List<Edge> adjList = graph.getAdjacencyList(v);
                for (int i = 0; i < adjList.size(); i++) {
                    g.addEdge(adjList.get(i).dest.val, adjList.get(i).src.val, 1);
                }
            }
            return g;
        }
private Graph reverseGraph ( Graph graph ) { Graph g = new Graph ( graph . V , graph . E ) ; for ( int v = 0 ; v < graph . V ; v ++ ) { List < Edge > adjList = graph . getAdjacencyList ( v ) ; for ( int i = 0 ; i < adjList . size ( ) ; i ++ ) { g . addEdge ( adjList . get ( i ) . dest . val , adjList . get ( i ) . src . val , 1 ) ; } } return g ; }
The function to get the reversed graph.
The function to get the reversed graph .