Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

grid_graph

grid_graph(dim, periodic=False)[source]

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.