如果为undirected graph就是dfs或者bfs,如果都能visit则为连通O(V+E).
如果为directed graph就先dfs或者bfs,再reverse direct,再dfs或者bfs,如果两次都连通则为strong connect
http://www.geeksforgeeks.org/connectivity-in-a-directed-graph/