Shortest Path Generator

by Tuğrul Yazar | April 30, 2012 02:10

This is the continuation of my scripting experiment within Grasshopper. Like the minimum spanning tree algorithm, this is also a famous problem of computational geometry; the shortest path problem. I’m now coding faster and understanding the namespace more easily in Grasshopper. This time, the challenge was implementing Dijkstra’s algorithm[1] for the Shortest Path Generator. Again, it’s a quite powerful algorithm, I even plan to use it in my current project. Although there is a faster alternative, Shortest [2]Walk-in Food4Rhino and it was already implemented as a native Grasshopper component in later versions, it was a good challenge in 2012. Like the minimum spanning tree algorithm, this script may contain bugs and miscalculations. For example, in 3D points, it sometimes seemed a little weird to me.

shortest path generator

This Grasshopper definition calculates the shortest path on a given line network and two points. It utilizes on Vb.net scripting component I wrote. Thus, no add-ons are necessary for it to work. This makes the code written in 2012 still usable in 2021. When you run the code, make sure that the startp and endp inputs are fed. Then, the script calculates the shortest path between the closest nodes from these points. It is a little messy code but I tried to comment on important lines. It is a kind of study-solve-and-forget project since I don’t remember the exact algorithm now. However, the recent project[3] we finished utilizes Space Syntax[4] graphs and I saw that most of the Space Syntax metrics are based on this and similar network calculations.

shortest path generator

If you want to download and use the Grasshopper file; would you consider being my Patreon? Here is the link to my Patreon page[5] including the working Grasshopper file for the Shortest Path Generator, and many more.

Endnotes:
  1. Dijkstra’s algorithm: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
  2. Shortest : https://www.food4rhino.com/en/app/shortest-walk-gh
  3. recent project: https://www.designcoding.net/spacechase-for-grasshopper/
  4. Space Syntax: https://www.designcoding.net/tag/space-syntax/
  5. Here is the link to my Patreon page: https://www.patreon.com/posts/shortest-path-95660127?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_creator&utm_content=join_link

Source URL: https://www.designcoding.net/shortest-path-generator/