Graphical Package

Hi everyone!

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

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 :exploding_head:

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.

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

Isovists Example

Cheers!
Álvaro

27 Likes

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?

2 Likes

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 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:

    1. ByPolygons, counting every input polygon as an internal obstacle (like a open square space where surrounding buildings will be all obstacles).
    2. ByBoundaryAndInternalPolygons, where there is a difference between polygons acting as boundary/external limits and internal obstacles (like a room with furniture or columns inside).
    3. ByLines, similar to ByPolygons but in this case lines don’t have any relationship between themselves.

    The purpose of BaseGraphs is to aid on the creation of VisibilityGraphs, so visible edges can be accurately created in particular cases where they are inside a polygon by being kept if it is a boundary polygon or discarded if internal. It also helps on the creation of Isovists.

  • VisibilityGraphs are created from BaseGraphs using Lee’s algorithm, 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 :slight_smile:
I will try to make more examples on future updates.

5 Likes

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.

1 Like

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

1 Like

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

1 Like