# Graphical Package

**URL:** <https://forum.dynamobim.com/t/graphical-package/22932>\
**Category:** Share\
**Tags:** package\
**Created:** [June 19, 2018, 10:01am UTC](https://forum.dynamobim.com/t/graphical-package/22932 "2018-06-19T10:01:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvpickmans](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alvpickmans/32/41236_2.png) [@alvpickmans](https://forum.dynamobim.com/u/alvpickmans)\
**Post date:** [June 19, 2018, 10:01am UTC](https://forum.dynamobim.com/t/graphical-package/22932/1 "2018-06-19T10:01:50Z")

</div>

Hi everyone!

I just wanted to share another package that I have been developing over the past few months, **Graphical**.

 ![ShortestPath-gallery](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3ff9e74a77d79708360173f6082e005ebfa88c18.png)

**Graphical** is just a kind of _disaster-box_ package which I use to implement algorithms that I find interesting and challenging. It all started over a year ago when someone planted on me the idea of automating the computation of shortest distance from fire hose cabinets to doors in Revit.

Althought it worked, it seemed that there was plenty of room for improvement (I mean, 20 seconds was too much for a simple layout like that one). So after researching and learning about visibility graphs, that led to shortest paths, which led to Dijkstra, which led to priority queues, which… led to me ending up lots of nights awake in front of the screen 🤯

**Graphical** package is very WIP (and I think it will always be) as I keep piling ideas and algorithms worth implementing. For now it provides methods to compute the visibility graph from a given set of boundaries (polygons), shortest path from two points on the given visibility graph and computation of isovist, among other utilities that I’ve built along the way.

I have tried to be as thourough as possible by checking and testing hundreds of times, but if anyone finds any bug please let me know via the [GitHub page.](https://github.com/alvpickmans/GraphicalDynamo)

Lastly, if someone has any ideas or comments I’ll be glad to know them!

_Isovists Example_  
https://player.vimeo.com/video/273986616

Cheers!  
Álvaro

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [June 19, 2018, 10:14am UTC](https://forum.dynamobim.com/t/graphical-package/22932/2 "2018-06-19T10:14:30Z")

</div>

Pinned globally on June 19, 2018, 10:14am UTC



---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 25, 2018, 3:44pm UTC](https://forum.dynamobim.com/t/graphical-package/22932/3 "2018-06-25T15:44:34Z")

</div>

This looks pretty great. Would you be willing to share your example files or create documentation on the initial setup required to run these graphs?

---

<div class="post-metadata">

**Author:** ![alvpickmans](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alvpickmans/32/41236_2.png) [@alvpickmans](https://forum.dynamobim.com/u/alvpickmans)\
**Post date:** [June 25, 2018, 8:30pm UTC](https://forum.dynamobim.com/t/graphical-package/22932/4 "2018-06-25T20:30:32Z")

</div>

Sadly I haven’t produced any documentation just yet, although there are a couple of sample files on the pacakge’s `extra/visibility` folder ([JsonData package](https://forum.dynamobim.com/t/jsondata-package/19026) is needed to deserialize the json file within).

Briefly explained. the `Graph` category is based on `BaseGraphs` and `VisibilityGraphs`:

- **BaseGraph** is a class that holds information about a set of polygons acting as limits on a layout. There are mainly three ways of creating **BaseGraphs** :

- **VisibilityGraphs** are created from **BaseGraphs** using [Lee’s algorithm](https://taipanrex.github.io/2016/10/19/Distance-Tables-Part-2-Lees-Visibility-Graph-Algorithm.html), which are then used to find the shortest path. The boolean `reduced` input simply gets rid of none tangent segments when `true` (default value).  

The key thing to start is to generate the **BaseGraph** , keeping in mind:

1. Input must be a list of polygons, so in cases where this is not the starting data there are a few nodes on the `Geometry` category to help generating them:
  1. **Curves.Polygonize** , to simplify a curve into a serie of straight lines by setting a maximum length (not the best way but it does work for now).
  2. **Curves.BuildPolygons** is a node that groups and creates polygons from a list of unsorted lines that are intersecting at extreme points and forming a closed curve.
  3. **Curves.GroupCurves** , similar to the above but accepting any type of curve and grouping them into polycurves so they don’t necessary need to be closed.

2. Graphs expect polygon, lines and points to be coplanar (horizontal plane?). So for example if polygons are at an elevation of +3000mm, points to calculate the shortest path should have the same elevation (pulled onto that plane).

Not sure if I’m missing something else for now, but let me know if anything is unclear 🙂  
I will try to make more examples on future updates.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 29, 2018, 2:12pm UTC](https://forum.dynamobim.com/t/graphical-package/22932/5 "2018-06-29T14:12:54Z")

</div>

That helped. I’ve got it working for possible egress paths now. Is there a way you could have the ShortestPath node return the actual curve as well? I’d like to be able to manipulate it a bit.

---

<div class="post-metadata">

**Author:** ![alvpickmans](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alvpickmans/32/41236_2.png) [@alvpickmans](https://forum.dynamobim.com/u/alvpickmans)\
**Post date:** [June 29, 2018, 2:16pm UTC](https://forum.dynamobim.com/t/graphical-package/22932/6 "2018-06-29T14:16:34Z")

</div>

Sure! you just need to use **BaseGraph.Lines** node to get the lines representing the output graph from ShortestPath node

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 29, 2018, 2:21pm UTC](https://forum.dynamobim.com/t/graphical-package/22932/7 "2018-06-29T14:21:19Z")

</div>

Ah! Perfect! I figured you had to have something like that in the package. I just didn’t look hard enough.
