there are N edges , so + 1 for nodes and + 1 for 1 - based indexing
g = [ [ ] for i in range ( N + 2 ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT addEdge ( g , edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ) NEW_LINE DEDENT print ( maxProductOfTwoPaths ( g , N ) ) NEW_LINE