public static void main(String args[]){
        Graph<Integer> graph = new Graph<>(true);
        graph.addEdge(0, 1);
        graph.addEdge(1, 2);
        graph.addEdge(2, 0);
        graph.addEdge(1, 3);
        graph.addEdge(3, 4);
        graph.addEdge(4, 5);
        graph.addEdge(5, 3);
        graph.addEdge(5, 6);

        StronglyConnectedComponent scc = new StronglyConnectedComponent();
        List<Set<Vertex<Integer>>> result = scc.scc(graph);

        //print the result
        result.forEach(set -> {
            set.forEach(v -> System.out.print(v.getId() + " "));
            System.out.println();
        });
    }
Date 10/01/2014
@author Tushar Roy

Given a directed graph, find all strongly connected components in this graph.
We are going to use Kosaraju's algorithm to find strongly connected component.

Algorithm
Create a order of vertices by finish time in decreasing order.
Reverse the graph
Do a DFS on reverse graph by finish time of vertex and created strongly connected
components.

Runtime complexity - O(V + E)
Space complexity - O(V)

References
https://en.wikipedia.org/wiki/Strongly_connected_component
http://www.geeksforgeeks.org/strongly-connected-components/
src/com/interview/graph/StronglyConnectedComponent.java