calling dfs on subtree rooted at i , edge from i to g [ i ] [ j ]
curMax = [ 0 ] NEW_LINE path2 = dfs ( g , curMax , i , g [ i ] [ j ] ) NEW_LINE res = max ( res , path1 * path2 ) NEW_LINE return res NEW_LINE