Connect Objects (Nodes) with Lines using an Adjacency Matrix

Hello everyone,

I’m working on a 3D ship design tool project , and I have a list of engineering components and their associated system connectivity which is represented by a large adjacency matrix in excel. I’ve attached a snip of the data below for an example.

These engineering components are represented by boxes, and are automatically loaded into rhino from Grasshopper from a known set of data.

My next goal is to have these boxes connected by lines or pipes in a way which provides a visual of how these components would be connected in a real ship and demonstrate the complexity of marine engineering systems. Nothing fancy needed here, just lines between boxes (grasshopper objects I have already created). The node names in the adjacency matrix are the same names as the boxes that have been created so I’m hoping I could avoid issues with matching nodes to objects.

I’m hoping there would be a way to import/read or convert the information from this adjacency matrix into a useable form in grasshopper.

Does anyone have any suggestions on how I should tackle this? I’ve looked at the parakeet, plan graph, and owl so far but I’m at a pretty significant roadblock with this issue.


I feel like you don’t need any fancy plugins to do what you want.
The main plugin you’d need is one to stream your Excel data in Grasshopper. (Bumblebee)

Basically what the adjacency matrix of yours show is that “POD1” is connected to “Propulsion”, but not in the opposite direction: a directed graph.

One way I would explore is

  • to import the values as a datatree (either a row per branch or column per branch)
  • Then I’d test the value 1 in all the branch and find every list indices on AND every branch indices they sit on.
  • Depending on the way you imported your values in Gh (as columns or rows), you can select the center points of your well ordered breps (center points, that have the same order as the label list) and connect them with the indices.

Sorry that’s probably a messy explanation… Let me know if you need more details on some steps.
Once you’ve imported the values in Grasshopper and that you have a list of brep in Grasshopper that match the order of the labels in your excel file, I’d be in a better position to help you :slight_smile:

That’s great advice! I’m going to attempt this today. I use lunchbox right now to read excel data, so I should be able to accomplish this.

Thanks for the advice so far. I’m getting an RPC error in my bumblebee script, do you know how I could resolve this? It was working earlier and I was almost able to set up my column data table. Excel Matrix is here.

AM example - Copy.csv (142.3 KB)

New Bumblebee VC (12.4 KB)

First step was to convert the csv into a proper table. In excel (Data>from txt/csv>pick the very same file)

Then here is the workflow for bumblebee

AM example - Copy.csv (142.3 KB)
New Bumblebee VC (7.2 KB)

Note that the first branch is {1} (I got tricked first time)
First branch is all your labels
next branches are all the data + the header on index 0.

Let me know if you need help on the next steps !

Actually I got bored at work so there you go :slight_smile:
put your points in the round group (they have to be in same orders as labels).
I went for native components except for bumblebee. (some step could be done faster)

New Bumblebee VC (15.4 KB)

That is so awesome! I took this code and combined it with my other code which is creating the boxes for all the components. I now have a full plate of pasta. You have helped me get so much progress, can’t thank you enough.

Currently, I am baking the boxes (breps) into 11 different layers based on their subsystems. Do you think there is a way to somehow link these connectivity lines to the breps as well since they all have the same name? I am using elefont to bake in the breps.

1 Like

Are you still bored at work, haha! I have a new issue that I’m attempting to resolve.

In the top tree
(0) is subsystem
(1) is Brep name,
(2) is X location of box,
(3) is y Location of box,
(4) is Z location of box.
(66),(67),(68) is the length, width, height of the box. Respectively

The end result of the top tree is that all of the Breps are baked into individual layers based on their subsystem name and are assigned a colour.

Using the bottom tree, do you think that there is a way in which I could connect all of the lines from the adjacency matrix to the objects which are created in the top tree? That way, I could bake the connectivity lines associated with each brep into their respective sub system layers. Then you would have a 3D model of all the components (breps) and how the equipment is connected.

Any advice would be awesome! Also, I’m attempting to use the center of the breps as the points for the connectivity lines, but I haven’t figured that out yet. There doesn’t seem to be a clear command for finding the center or centroid of a brep.

VC Boxes by Subsys Layer (44.1 KB)

VC Boxes by Subsys Layer 31OCT Internal (176.8 KB)


Didn’t see your previous message, I’m happy it helped !

I’m not gonna lie, I don’t get what you’re trying to do :slight_smile:
What is a top and bottom tree? Level of branch nesting? Higher branch count? a tree at top or bottom of the canvas? I’m confused…

I went in the code, hoping it would make more sense but it didn’t :smiley:

Btw for centroid, you can use Volume component… BUT these are the centers, so you don’t need to recompute them.

Also the part I highlighted in red seems incorrect. I could be wrong, but you might wanna double check that.

I can help you, but I’d need a better explained version of the problem, with some explanation or names in the grasshopper file if needed, remember I have very little to no knowledge about your project/task :slight_smile:
Cheers !
VC Boxes by Subsys Layer 31OCT Internal (160.7 KB)

Thanks for your response, that is very embarrassing on my part that I didn’t provide enough information. I apologize. ‘VC’ stands for ‘Vital Component’ which means pieces of engineering equipment. I have put A LOT more description information into the grasshopper file this time. I’ve matched the description below with the code for easy reference. I’ve also included three panels with questions that I am trying to solve.

This is what I am trying to do:

  1. Create Vital Component (VC) Boxes based on the length, width, height information that I have labeled in the code ** Length, Width, Height of Boxes**

  2. Move these boxes to the X,Y, Z locations that are where the center of these boxes should be **(X,Y, Z Locations for Center of VC Box) **

  3. Organize these boxes by their assigned Subsystem ** VC Boxes assigned Subsystem**.

  4. Bake all of these VC boxes with their names and assigned Subsystem into individual layers

  1. I’m attempting to map out all the connectivity (directed graph) information for these boxes. Because these VC components are connected in real life as parts of systems, I’m attempting to display these connections between VC Boxes using the adjacency matrix information that we have been investigating together. The VC boxes are named in the exact same order as the first column of the Adjacency Matrix (which is the names for these VC Boxes)

  2. Using elefont, I would like to bake these VC connections into Rhino and have these connection lines ‘match up’ with their respective VC boxes. That way, you can see all of the components (VC Boxes), where those are located, and then Also what other VC Boxes they are connected to. Another goal would be that when you move a VC box manually, its connection lines are coupled to the box and those move as well.

The reason I was investigating finding the center of the boxes is because I was assuming that I would need to connect the two VC components together through their center point. It seems that I am mistaken in this.

VC Boxes by Subsys Layer 31OCT Internal (177.0 KB)

Thanks for the details !
Here’s what I think…

The code I provided before should work and connect the centers based on the adjacency matrix.
If it is not the case (which I guess it’s not), there might be two reasons…
Either your center points order don’t match the order of the labels
Or the fact that from your 264 points, only 23 are unique. (use Create Set to see the actual number of unique points).

5.2 (second panel about center boxes)
There’s a problem for that with the current configuration. I would have a separate definition for that.
Once you’ve baked the boxes, you would have another definition reading the boxes from rhino (Dynamic Pipeline from Human plugin, or actually Elefront since it can also listen to rhino changes), use the adjacency matrix the exact same way it’s been used in this definition, but remeber to use Volume to get your brep centers.

If by coupled you mean that when moving a box, the connections follow, refer to 5.2
If something else, sorry I’d need more details :smiley:

When checking a bit the data, there should be boxes that are not connected, since the number or items is smaller than the number of branches. (top left in the image below)
The adjacency matrix also suggests that, for example, one boxe receives up to 45 connections… Is that the case?

VC Boxes by Subsys Layer 31OCT Internal Data (1).gh (171.1 KB)

Well … the bad news is that you can’t do many things without code. I’m talking having the general case in mind: given Nodes (points) and a valid adj Matrix and any Meta Data … do a graph and then extract and present ANY kind of information imaginable.

Have a look in the attached entry level demo where (a) a pts List (named V) and (b) an Adj Matrix are the inputs. Then connections (E for edge) are computed PLUS the critical 3 connectivity Trees (I do hope that you know what connectivity is - if not abandon ship).

A “basic” visual clue upon what’s happening (via Text Dots that display indices) is provited. In real-life the V should been assosiated with a String List (i.e. Node Names) PLUS anything else like the importance (flat, nested etc etc) of the Nodes/Connections. Then … anything is possible (for instance if you have Instance Definitions [corresponding 1:1 to your V List] represending some instruments … blah, blah). (141.4 KB)