Graphviz source reference with c#

Hello everyone!

I’m developing a graphViewer app in C#(VS). My code creates a Dot file and passes the parameters of dot process with ProcessStartInfo in order to get the text output of the dot graph from graphviz(-Tplain). Which I then use to get the coordinates of the nodes and edges.
Is there a way to directly call the dot.c source code to do this?(maybe referencing) That is, without having to use the dot.exe from graphviz.

I tried looking for some graphviz c# libraries that offer this functionality, but it is either not offered, or the lib project has been abandoned for years. But I could also have misjudged the usability of some of them.

This is my first using forums by the way.
Thanks for your help!


I don’t think we have official C# graphviz bindings. But maybe the community has made some.

You might have an easier time parsing -Tjson output rather than plain?

I would probably encourage making a process call rather than library. Then you can put a timeout on it, and when it takes too long, cancel it. And when it hits bugs it won’t take down your app.

1 Like

In theory there are C# bindings in the Graphviz tree (--enable-sharp=yes to ./configure). But I doubt any of the downstream packaging ecosystems enable this. In particular, I know the main vector for shipping Graphviz on Windows (Chocolatey) does not, because it is using the CMake build system which does not support the C# bindings. We’re working on plugging this gap (cmake parity (#2530) · Issues · graphviz / graphviz · GitLab).

1 Like

I haven’t tried parsing with -Tjson, this could in fact make it faster and easier. I will try it, thank you for the tip.
It does make sense to have the process call, and that is the way I’m currently using it.
But, if I one day deploy the app, every user would need to already have graphviz installed, right?
I was trying to maybe avoid this, and have every needed resource be already inside the deployed application.

You could bundle graphviz with your app. Just make sure you include a copy of our license to comply with it.

1 Like