Integrating graphviz with unity


I am new to graphviz, which got recommended to me because I wanted to visualize graphs that I created in Unity. So currently, I have no idea how to use it.

I have some C# Scripts that allow users to type in to a textbox in Unity the all the nodes, edges and weights, then convert that in to a graph, represented using an adjacency list when the user clicks the “done typing” button. However, I wanted to visualize the graph, not just storing it as some data structure in computer memory.

So is there a way of integrating graphviz with unity, so that after the adjacency list is created (using C#), I can somehow send that to graphviz and get a image of that graph, which will then be displayed in Unity UI?

I am ignorant. What is Unity? And what OS?
At a very high level:
If there is no api available for your language:

  • create a text file. e.g.
digraph mine {
  { node[shape=point width=.01] p1 p2}
  a -> p1 [headclip=false arrowhead=open ] 
  p1 -> b [dir=none tailclip=false]
  b -> p2 [headclip=false]
  p2 -> c [dir=none tailclip=false]
  • some kind of system call: dot -Tsvg mynewfile.gv > mynewfile.svg
  • display the output file

If there is an api available (python, c, c++, java, …), you can combine all three steps (no real text file needed)

Thank you for your reply!

I am using Windows 10 OS; Unity is a game engine I am using currently for making a game, it uses C# scripts to run the game. So I’m wondering if I can visualize graphs using just C# code and possibly graphviz integration.

The text file makes sense to me, but I’m not sure how to do the system call.

Graphviz’ Autotools build system produces C# bindings, for which you can see example usage in tclpkg/gv/test.cs · f9293d0d3d625dc31816f9e864045542a590f14e · graphviz / graphviz · GitLab. Though I don’t know what state these are in or whether anyone is using them.