Algorithm for finding internally connected cluster of nodes within a graph from which no edge points outwards

I am representing my graph as a adjacency list. I want to know how can I find a cluster of nodes which are internally connected but no edge points outwards from them. Is there any well known algorithm out there which I can use?

for e.g.This is my graph.


Here nodes 4 and 5 are internally connected. Yet no outside edge comes from this. This would be my answer. Similarly nodes 1,2,3 even though they form a cycle, do not fit the criteria as an outside edge emanates from node 3. So it is not same as finding a cycle in a adjacency list.

Optional read: (why I need this) I am working on a Ranking page (search engine) algorithm, nodes like 4 and 5 are called rank-sink.


You could detect strongly connected components using Kosaraju, Tarjan or Cheriyan-Mehldorn/Gabow algorithm.

After finding these components, you compress each strongly connected components into one single node (i.e. you represent a whole component by a single node).

In the resulting graph, you look for nodes with no outgoing edges. These nodes represent the components you are interested in.


 ? Algorithm to find a random Hamiltonian path in a grid?
 ? find all non-repeating paths through a set of connected nodes/process diagram
 ? graph algorithms: reachability from adjacency map
 ? Cycles in a directed graph
 ? Diagram connector algorithm
 ? detailed hungarian algorithm(assignment problem) question
 ? Number of ways to reach a node with minimum cost from a fixed node
 ? Is Dijkstra's Algorithm just BFS where you also tally node weights?
 ? Equal cost multipath Dijkstra's Algorithm in python
 ? Using Dijkstra algorithm to compute shortest path between two nodes