I believe others have already explained what each line does well. I'm just pointing out that in the second line,
Edge &e = g[u][j];
the code places the Edge at g[u][j] in a reference, presumably, to make the following code easier to both read and write (instead of repeating g[u][j] multiple times).