networkx.generators.lattice.grid_2d_graph¶
-
grid_2d_graph
(m, n, periodic=False, create_using=None)[source]¶ Returns the two-dimensional grid graph.
The grid graph has each node connected to its four nearest neighbors.
Parameters: - m, n (int or iterable container of nodes) – If an integer, nodes are from
range(n)
. If a container, elements become the coordinate of the nodes. - periodic (bool (default: False)) – If this is
True
the nodes on the grid boundaries are joined to the corresponding nodes on the opposite grid boundaries. - create_using (NetworkX graph (default: Graph())) – If provided this graph is cleared of nodes and edges and filled with the new graph. Usually used to set the type of the graph.
Returns: The (possibly periodic) grid graph of the specified dimensions.
Return type: NetworkX graph
- m, n (int or iterable container of nodes) – If an integer, nodes are from