WLJS LogoWLJS Notebook

GridGraph

GridGraph[{m, n}] gives the m×n grid graph. GridGraph[{n1, n2, ..., nk}] gives a k-dimensional grid graph.

Examples

Create 2D grid:

GridGraph[{4, 5}]
(* 4x5 grid with 20 vertices *)

3D grid:

GridGraph[{3, 3, 3}]
(* 27 vertices *)

Vertex and edge counts:

{VertexCount[GridGraph[{3, 4}]], EdgeCount[GridGraph[{3, 4}]]}
(* {12, 17} *)

Please visit the official Wolfram Language Reference for more details.

On this page