Symbols and Functions > Utility Functions >
GeneralizedGridGraph is similar to GridGraph, but
it allows for additional specifiers in each direction of the grid:
In[] := GeneralizedGridGraph[{5 -> "Directed", 5 -> "Circular"}]Possible specifiers are "Directed" and "Circular", and they can be combined:
In[] := GeneralizedGridGraph[{3 -> {"Directed", "Circular"}, 6}]The same options as GridGraph are supported. In
addition "VertexNamingFunction" -> "Coordinates" names vertices according to their position in a grid:
In[] := GeneralizedGridGraph[{4, 5, 2},
"VertexNamingFunction" -> "Coordinates", VertexLabels -> Automatic]Finally, it's possible to use different EdgeStyle in different directions by specifying it as a list:
In[] := GeneralizedGridGraph[{4 -> "Directed", 5, 2},
"VertexNamingFunction" -> "Coordinates",
EdgeStyle -> Darker /@ {Red, Green, Blue}]![Out[] = ... 5x5 grid graph, directed and circular on different dimensions ...](/maxitg/SetReplace/raw/7b4fabdc33857213970323e2e94d4b9fefdf46ed/Documentation/Images/GridGraph.png)
![Out[] = ... 3x6 grid graph, directed and circular on the first dimension ...](/maxitg/SetReplace/raw/7b4fabdc33857213970323e2e94d4b9fefdf46ed/Documentation/Images/DirectedCircularGridGraph.png)
![Out[] = ... 4x5x2 grid graph with vertices labeled by their coordinates ...](/maxitg/SetReplace/raw/7b4fabdc33857213970323e2e94d4b9fefdf46ed/Documentation/Images/GridGraphWithCoordinateNamedVertices.png)
![Out[] = ... 4x5x2 grid graph with edges colored red, green, and blue in different directions ...](/maxitg/SetReplace/raw/7b4fabdc33857213970323e2e94d4b9fefdf46ed/Documentation/Images/GridGraphWithDifferentEdgeStyles.png)