Function to find the maximum shortest path distance in a component by checking the shortest distances between all possible pairs of nodes
int maxInThisComponent ( vector < int > & component , vector < vector < int > > & graph ) { int maxDistance = INT_MIN ; int n = component . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { maxDistance = max ( maxDistance , graph [ component [ i ] ] [ component [ j ] ] ) ; } }