Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to easily draw graphs in WPF? [closed]

Tags:

c#

.net

graph

wpf

I need to draw graphs representing finite state machines. I tried to use Graph#. It's cool, but it lacks some things. There is no documentation, which makes it very difficult to use, I cannot draw loops (edges from a vertex to itself) using its custom WPF control and labeling edges is also not implemented. Is there any other library o adviced way of drawing graphs in WPF?

Functionality I need:

  • edge labeling
  • loop (cyclic) edges
  • vertex labeling
  • drawing single/double circles around vertices - vertices should be represented either as circle (or double circle) with a label inside

Any ideas?


EDIT:

I got some propositions, for which I am grateful. However, I think I have not made my thought clear. I need this kind of graph:

http://static.max99x.com/school/automata-editor1.png.

All tools suggested as far are not suitable for this or maybe I don't know how to apply them in this situation.

like image 329
pmichna Avatar asked May 10 '13 10:05

pmichna


Video Answer


2 Answers

Option 1: Microsoft Automatic Graph Layout

Free

http://research.microsoft.com/en-us/projects/msagl/

GitHub

https://github.com/Microsoft/automatic-graph-layout.git

Winforms >> WPF

It's WinForms, but it can be imported into WPF with a few lines of code.

Visualizing Nodes and Edges with Microsoft Automatic Graph Layout

http://www.codeguru.com/csharp/.net/net_wpf/article.php/c16963/Visualizing-Nodes-and-Edges-with-Microsoft-Automatic-Graph-Layout.htm

Examples

http://research.microsoft.com/en-us/projects/msagl/#Layouts

FAQ

http://research.microsoft.com/en-us/projects/msagl/faq.aspx

Option 2: QuickGraph - A 100% C# graph library with Graphviz Support

Free

http://quickgraph.codeplex.com/

This library is 100% C#. Don't be misled by the line "Graphviz Support", this means that it uses C# code to import the output from Graphviz. No C++ code in sight.

http://www.codeproject.com/Articles/5603/QuickGraph-A-C-graph-library-with-Graphviz-Sup

Has a NuGet package.

Under development from 2003 to 2011 (8 years!!).

Option 3: GraphSharp

Free

http://graphsharp.codeplex.com/

  • Depends on QuickGraph (which is 100% C#).
  • Supports async/await (nice!).

Demo

https://sachabarbs.wordpress.com/2010/08/31/pretty-cool-graphs-in-wpf/

Notes

This one worked really well, was up and running in a couple of hours. It also supports DataTemplates, so each node can have any look and feel that you want.

Option 4: Graphviz4net

Free

http://graphviz4net.codeplex.com/

Option 5: GoDiagram

$$$

http://www.nwoods.com/products/godiagram/index.html

Option 6: A Graph Tree Drawing Control for WPF

Free

http://www.codeproject.com/Articles/29518/A-Graph-Tree-Drawing-Control-for-WPF

No suitable. It's a tree layout.

Option 7: Using WPF to Visualize a Graph with Circular Dependencies

Free

http://www.codeproject.com/Articles/43776/Using-WPF-to-Visualize-a-Graph-with-Circular-Depen

Option 8: GraphViz

Free

http://www.graphviz.org/Download..php

This is not C#, and uses non-managed code. There are C# wrappers for it, however.

Opensourced by AT&T, see "AT&T Researchers — Inventing the Science Behind the Service", and "research home > portfolio > software tools": http://www.research.att.com/software_tools?fbid=NEk8_gxLLEc

Source

http://www.graphviz.org/Download_source.php

They also open sourced Rserve!

Option 9: Shields.GraphViz

Free

Wrapper for GraphViz.

https://github.com/timothy-shields/graphviz

Option 10: NetworkView: A WPF custom control for visualizing and editing networks, graphs and flow-charts

Free

http://www.codeproject.com/Articles/182683/NetworkView-A-WPF-custom-control-for-visualizing-a

This library allows the user to create connections between nodes, which is probably a bit of an overkill.

Example

https://channel9.msdn.com/coding4fun/blog/Noodling-Network-Nodes-Diagraming-with-the-NetworkView-custom-WPF-control

It's all MVVM.

Option 11: Gephi - The Open Graph Viz Platform

Free

See http://gephi.github.io/

Not a WPF graphing library, but provides great examples of how really nice graphs can look. The tutorial is excellent.

Option 12: Telerik

$$$

http://www.telerik.com/products/wpf/diagrams.aspx

Option 13: Infragistics

$$$

http://www.infragistics.com/samples/wpf/network-node/overview http://www.infragistics.com/samples/wpf/network-node/relationship-between-nodes http://www.infragistics.com/samples/wpf/network-node/custom-node-style

Option 14: WPF Diagram Designer

Free

Not so much graphing tool, but it does show you how to move, resize and rotate objects of any type on a canvas.

http://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1

Option 15: MVVM Diagram Designer

Free

And, somebody reimplemented this in MVVM: Not so much graphing tool, but it does show you how to move, resize and rotate objects of any type on a canvas.

http://www.codeproject.com/Articles/484616/MVVM-Diagram-Designer

Option 16: yWorks - The Diagramming company

$$$

https://www.yworks.com/en/products_yfiles_practicalinfo_gallery.html https://www.yworks.com/en/products_yfileswpf_about.html

Option 17: MindFusion

$$$

http://www.mindfusion.eu/features-wpfdiagram.html http://www.mindfusion.eu/

Option 18: Dot2WPF

Free

A WPF control for viewing DOT graphs.

http://www.codeproject.com/Articles/18870/Dot-WPF-a-WPF-control-for-viewing-Dot-graphs

Option 19: SyncFusion

$$$

https://www.syncfusion.com/products/wpf/diagram

Option 20: AddFlow

$$$

https://www.componentsource.com/product/addflow-wpf-standard

Option 21: Lassalle

$$$

http://www.lassalle.com/

Option 22: Dynamic Data Display

http://dynamicdatadisplay.codeplex.com/

Option 23: Nevron

$$$

https://www.nevron.com/

Only for WinForms, but can be imported into WPF. However, each individual item cannot be templated, which is a big advantage of WPF solutions.

Google Search Terms

  • "workflow wpf graphing"
  • "wpf graphing library"
  • "wpf state machine library"
like image 65
Contango Avatar answered Sep 20 '22 11:09

Contango


Graphviz + GraphViz C# Wrapper are exactly what I was looking for.

like image 29
pmichna Avatar answered Sep 19 '22 11:09

pmichna