Using GraphViz in a WPF application
I want to use GraphViz in my WPF开发者_如何学C application without installing Graphviz.
Does AT&T (or somebody else) distribute such a DLL?
Thanks, Kemal
You can compile the dot tool as DLL from source. That is what I did a while back. I use QuickGraph with GraphViz and render the graph with slightly modified version of the control you can get from here http://www.codeproject.com/KB/WPF/Dot2Wpf.aspx
Apparently ImageMagick can read the graphviz DOT format: http://www.imagemagick.org/script/formats.php
Perhaps you can call ImageMagick from .NET using this wrapper http://imagemagick.codeplex.com/ and get it to read DOT and output as PNG or something? I've never tried, and for all I know ImageMagick might end up spawning the command line program anyway!
(I have used graphviz from ASP classic a long time ago by spawning the graphviz executable with good results BTW.)
Just use the "GraphViz XAML Renderer" @ http://www.sixpairs.com/graphviz/graphviz.aspx
Features:
- No need to install GraphViz
- No need to launch an external process
- No need to use files
- Thread safety
Regards,
Ciper
Try graphviz library .NET wrapper http://code.google.com/p/graphviznet/.
It accepts the description of a graph in the form of managed objects, runs through the graphviz layout engine and gets back the data.
If you don't want't to install complete graphviz, you can copy only required set of dll's, see readme.txt in demo project, project also contains a WPF control to display graphs.
Licensing
GraphViz is licensed under the Common Public License (see the CPL FAQ)
Also from the GraphViz site:
For more information on the Common Public License, see the FAQ. If you have any concerns about the what the license means, especially if money is involved, you should contact an intellectual property lawyer.
Using GraphViz as a DLL
GraphViz is an executable program rather than a DLL - to use it in your app you need to spawn the executable with the correct command line parameters and pick up the resulting output.
Other ways of using GraphViz
There is a COM component available that parses the DOT language and renders it: WinGraphViz but I've never used it and cannot vouch for how well it works.
Aside: If you are doing graph work in WPF I thoroughly recommend using QuickGraph to actually manage the graph - it will also output to GraphViz compatible text files.
Have a look at this fairly new object-oriented Graphviz wrapper for .NET: https://github.com/Rubjerg/Graphviz.NetWrapper
Since it works by doing foreign function calls to the Graphviz library it ships with, you don't have to install anything.
精彩评论