How to identify near-connected nodes in an adjacency matrix?

  adjacency-matrix, c++, graph

Say you have an adjacency matrix:


1s represent nodes that are connected to other 1s, and 0s are unconnected.
The last 1 in the 2nd row is almost connected to the others. It’s separated by one node. How do you identify occurrences like that? My initial though it to have some sort of distance function that returns the smallest distance from the separated node to one of the nodes in the connection, and determine if it is "almost" connected based on a min distance (like 1 node).

That seems a bit convoluted though. Is there a better way to approach this?

Source: Windows Questions C++