Determine if a set of nodes in a graph is a cluster
===

If I have a grid-like graph and a set of nodes like [A,B,J,K].

    Grid Graph:

    A B C D
    E F G H
    I J K L

    Note: diagonals not considered neighbours
       

What is the best way to check if those nodes are all adjacent AND form a cluster?

In the example above, [A,B] are adjacent and [J,K] are adjacent but as a whole, the set does not form a cluster. If 'F' was added to the set to form [A,B,F,J,K], then I would consider it a cluster.

**Updated:** I already have a function that checks if two nodes are adjacent boolean isAdjacent(Node a, Node b). Just need to expand on it to check for the cluster.