Show Path with Arrows in a Matrix

Easily style vertices, edges, and their labels, and apply interesting functions. For a small increase in code sophistication, you gain quite an advantage.

    
Define a path:
In[46]:=
Click for copyable input
Define the edge shape function:
In[47]:=
Click for copyable input
Create the path graph:
In[48]:=
Click for copyable input
Out[48]=
Create the overall grid:
In[49]:=
Click for copyable input
Out[49]=
Overlay them:
In[50]:=
Click for copyable input
Out[50]=
A different approach uses GridGraph with the GraphHighlight option:
Click for copyable input
Click for copyable input
Highlight the path:
Click for copyable input
Add arrows to indicate the path direction:
Click for copyable input
Click for copyable input
New to Mathematica? Find your learning path »
Have a question? Ask support »