Return the n-dimensional grid graph.
The dimension is the length of the list ‘dim’ and the size in each dimension is the value of the list element.
E.g. G=grid_graph(dim=[2,3]) produces a 2x3 grid graph.
If periodic=True then join grid edges with periodic boundary conditions.