Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a triangular grid graph with customizable width and height, represented as a parallelogram composed of triangular grids
ResourceFunction["GeneralizedTriangularGridGraph"][{width, height}] generates a triangular grid graph with the specified width and height. |
Form a triangular grid graph four elements wide and three tall:
In[1]:= | ![]() |
Out[1]= | ![]() |
This graph is three elements wide and four tall:
In[2]:= | ![]() |
Out[2]= | ![]() |
Specify VertexLabels:
In[3]:= | ![]() |
Out[3]= | ![]() |
Make a grid graph of 57 by 57:
In[4]:= | ![]() |
Out[4]= | ![]() |
A graph of 58 by 58 will not plot:
In[5]:= | ![]() |
Out[5]= | ![]() |
The output is nevertheless a graph:
In[6]:= | ![]() |
Out[6]= | ![]() |
Use GraphPlot to show it:
In[7]:= | ![]() |
Out[7]= | ![]() |
Color the background:
In[8]:= | ![]() |
Out[8]= | ![]() |
Change the layout:
In[9]:= | ![]() |
Out[9]= | ![]() |
Choose a vertex shape function:
Make the image large:
In[10]:= | ![]() |
Out[10]= | ![]() |
Use built-in settings for VertexShapeFunction in the "Basic" collection:
In[11]:= | ![]() |
Out[11]= | ![]() |
Simple basic shapes:
In[12]:= | ![]() |
Out[12]= | ![]() |
Use built-in settings for VertexShapeFunction in the "Rounded" collection:
In[13]:= | ![]() |
Out[13]= | ![]() |
In[14]:= | ![]() |
Out[14]= | ![]() |
Get a list of built-in settings for EdgeShapeFunction:
In[15]:= | ![]() |
Out[15]= | ![]() |
Undirected edges including the basic line:
In[16]:= | ![]() |
Out[16]= | ![]() |
Lines with different glyphs on the edges:
In[17]:= | ![]() |
Out[17]= | ![]() |
Directed edges including solid arrows:
In[18]:= | ![]() |
Out[18]= | ![]() |
Line arrows:
In[19]:= | ![]() |
Out[19]= | ![]() |
This is similar to GridGraph:
In[20]:= | ![]() |
Out[20]= | ![]() |
There's also the resource function HexagonalGridGraph which tiles the plane with hexagons:
In[21]:= | ![]() |
Out[21]= | ![]() |
The function TriangularGridGraph does not support different height and width specifications:
In[22]:= | ![]() |
Out[22]= | ![]() |
This function supports different height and width dimensions:
In[23]:= | ![]() |
Out[23]= | ![]() |
Make a short wide graph:
In[24]:= | ![]() |
Out[24]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License