cosmograph-org / cosmos

GPU-accelerated force graph layout and rendering
Other
797 stars 53 forks source link

Question: Using only the simulation and skipping visualization? #27

Open baughmann opened 1 year ago

baughmann commented 1 year ago

First of all, this seems like a truly awesome library. I've thought for a long time about trying to do force simulations on the GPU myself because I felt like that was the key element missing in scalable client-side graph viz tools. Bravo to you all! You hit the nail on the head with this! I can only imagine the headaches that you all have saved people like myself from...

Now, to my question: How difficult is it to use exclusively the simulation aspects of this library, and how would one go about this?

I wish to have a great deal of control over visualization in my application, and I'm confident in the viz's performance at scale. However, I've always struggled with scaling the layout computation. I have not (yet) had the chance to dig through the source or attempt to use this library, though I hope to get the chance to change that very, very soon.

I'd assume that while most users would only want a "graph-in-a-box" solution, many would probably have similar desires as myself. Could you explain if this is possible, and, if so, where to start looking?

I can only imagine that when one is using WebGL for both computation and visualization in a library like this it can be extremely tempting to closely bind the simulation and visualization aspects for simplicity's sake (and probably a bit to minimize latency as well), but I'm wondering if that decision was made here?

Thanks in advance! Looking forward to getting to play with this! I've waited a long time for something like this to pop up!

rokotyan commented 1 year ago

@baughmann Thanks for your kind feedback, we're always happy receive reviews like yours!

Initially we didn't think about using Cosmos for layout calculations only, mainly because in order to run WebGL you'll still need initialize a web view. But since that question comes over and over again, I think it's worth doing some tests. While we do render directly from GPU memory, I don't think the shaders that do the calculations and rendering depend on each other. So in theory they can be separated, we'll certainly add that idea to our list.

baughmann commented 1 year ago

@rokotyan Great to hear I'm not the only one who's asked about this.

While still having to maintain a (possibly duplicate) WebGL instance just for this calculation does add non-insignificant overhead, the potential payoff in layout simulation times could well be worth it.

I have added this to my own list of things to play around with as well. If it were to become a feature (or even a separate layout engine library), another possible feature to think about would be additional layout "plugins" similar to Cytoscape.js that will allow users to implement additional layout algorithms. Of course, while not all algos benefit equally from GPU parallelization, it feels like there may be a lot of promise here!

rokotyan commented 1 year ago

@baughmann Absolutely! I'll keep this ticket open and once we have any news I'll post them here.