grid_graph

grid_graph(dim, periodic=False)[source]

Return the n-dimensional grid graph.

‘dim’ is a tuple or list with the size in each dimension or an iterable of nodes for each dimension. The dimension of the grid_graph is the length of the tuple or list ‘dim’.

E.g. G=grid_graph(dim=[2, 3]) produces a 2x3 grid graph.

E.g. G=grid_graph(dim=[range(7, 9), range(3, 6)]) produces a 2x3 grid graph.

If periodic=True then join grid edges with periodic boundary conditions.