Using networkx with the rhino.compute.appserver

Hi, I’m making my first attempt at creating a web app. The project is to handle minimum k-partitioning of rectilinear polygons. I have everything working at a sort of intermediate step; I have a locally-hosted example on the rhino.compute appserver where I’ve written the logic for the UX in three.js, I use rhino3dm to convert three.js points into degree-1 NurbsCurves and I’m able to retrieve the curves generated by my grasshopper file:

which consists entirely of a ghPython component.

My issue is that my ghPython script currently only handles non-degenerate partitioning. In order to expand the definition to first perform degenerate partitioning I wanted to enlist the aid of Networkx to build a bipartite graph and find the maximum independent set of its vertices. However, having read through other posts here, I’m under the impression that importing Networkx and its dependencies into ghPython is impossible.

I’m now stuck trying a bunch of different things which I have no experience with and I wanted to ask if anyone has advice with using Networkx or similar unsupported python packages. My options as I see them are:

  1. circumvent Networkx by writing the functions I need within my current ghPython script

  2. Break up my ghPython code into two files. The first would digest the curves, so I’d call from the appserver. Then I would pass that output to a python script (say, run from a spawned child-process and feed its output to the second grasshopper file ( The issue I’ve already run into here is that the output of is a list of custom class instances. I haven’t been able to find a definite answer online yet but it seems like the only allowable outputs from RH_OUT groups are primitive objects? When I’ve tried to output these intermediate values the client receives empty data trees.

  3. Something to do with Hops? I’ve never used it and am a little unclear if this is an appropriate use-case

  4. Since my grasshopper file is just one ghPython component, I was wondering if I could just rewrite it using so that I could perform step 2 in less steps.

  5. Something I haven’t yet though of

The second option is the most appealing to me at the moment because it seems like the least amount of work but I’m not sure if it’s possible. Any thoughts or advice would be greatly appreciated!