Function to find the maximum shortest path distance in a component by checking the shortest distances between all possible pairs of nodes
function maxInThisComponent ( component , graph ) { let maxDistance = Number . MIN_SAFE_INTEGER ; let n = component . length ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { maxDistance = Math . max ( maxDistance , graph [ component [ i ] ] [ component [ j ] ] ) ; } }