/*Draw a graph described by a string writed in the dot's syntax of Graphviz
NOTE: Open Visual Studio as Administrator*/
public static Image drawGraph(String graph_in_DOT) {
WINGRAPHVIZLib.DOT dot = new WINGRAPHVIZLib.DOT();
WINGRAPHVIZLib.BinaryImage img = dot.ToPNG(graph_in_DOT);
byte[] imageBytes = Convert.FromBase64String(img.ToBase64String());
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
}
This snippet return a Image object (for uses at a PictureBox control in a Form).
For correct functioning is necessary:
Install Graphviz ( http://graphviz.org/Download_windows.php)
Install WinGraphviz ( http://wingraphviz.sourceforge.net/wingraphviz/)
Import the reference to dll file at the project in Visual Studio (C:\Program Files (x86)\WinGraphviz\WinGraphviz.dll)
Add the using statement to the class for using the WinGraphviz components (using WINGRAPHVIZLib;).
For correct functioning is necessary:
Install Graphviz ( http://graphviz.org/Download_windows.php)
Install WinGraphviz ( http://wingraphviz.sourceforge.net/wingraphviz/)
Import the reference to dll file at the project in Visual Studio (C:\Program Files (x86)\WinGraphviz\WinGraphviz.dll)
Add the using statement to the class for using the WinGraphviz components (using WINGRAPHVIZLib;).
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.