What options are available for the layout of directed or undirected graphs in .NET?

只愿长相守 提交于 2019-12-09 04:15:25

问题


By graph here I mean something resembling these images:

The ideal solution would:

  • use only managed code
  • allow output to a bitmap image
  • allow output to WPF elements
  • include some kind of interactive surface for displaying the graph that supports zooming, panning and reorganisation of nodes

I'm also interested in hearing about projects that could potentially be used as the starting point for this kind of work. If it requires some development to achieve what I want, then I'm prepared to tackle it. The most complex portion of this goal seems to be obtaining the graph layout in a reasonable time frame.


回答1:


Graph# is also another option. I haven't used it personally, but I've been meaning to get around to looking over it.




回答2:


Microsoft Research provides a tool called MSAGL (Automatic Graph Layout, previously called GLEE) for .NET.

MSAGL is available here: http://research.microsoft.com/en-us/downloads/f1303e46-965f-401a-87c3-34e1331d32c5/default.aspx

Disclaimer: I haven't used the tool so I don't know whether it is suitable for you (and neither do I know about the licensing conditions, seems it is for non-commercial applications only). But at least it looks interesting.




回答3:


I am working in the NDepend team and I confirm: we switched from GraphViz to MsAgl in september 2008 and also the MsAgl license allows indeed commercial utilisation. Here are a few sample pictures of MsAgl graphs integrated in NDepend (everything is interactive, nodes are movable/selectable/removable/clickable, edges are editable/selectable/removable/clickable, the layout is zoomable, and also, while it could be cleaner the MsAgl API is clean enough to work with):




回答4:


Graphviz is still today, in my opinion, one of the best graph library there is. However, integrating it to .Net is a pain.

It is possible to call the command line tool to generate a shape output based on your graph input, then you read the output and lay the elements on a custom control that displays whatever shapes graphviz has calculated. It's very hacky but it's the best way our team have found of integrating graphviz with .Net a few years ago.

A better solution might exist today; at that time GLEE was still very embrionic and I haven't seen the progress Microsoft did since that time.




回答5:


I have used NodeXL, http://www.codeplex.com/NodeXL, which is a .Net 3.5 library (but also an Excel add-on). NodeXl is developed by Microsoft Research and pretty neat: it has visualization algorithms and some metrics but it is still in its early stages of development. If you have are a seasoned .Net developer then I would definitely take a look at it.

However, if you know Python then I would definitely recommend Networkx and its cousin pygraphviz which is an interface to Graphviz. I have used both and my productivity with Python / Networkx is way higher then when I was using NodeXL.

GLEE is Microsoft's closed source library that you only can use for free in non-commercial software while NodeXL is Microsoft's way of open source but you can use it freely in a product you develop.




回答6:


Just to make the list of options complete: Graphviz4Net is open-source implementation of what Coincoin has suggested in his answer.




回答7:


The boys at Mindscape have such a tool

With the imaginative name WPF Flow Diagrams

Also, check out Vertigo's Family.Show demo project, it has a simple form of this




回答8:


Use QuickGraph to output Dot files for GraphViz. I did that in a recent project, and it seems to work quite well. Look here for sample code for parsing .plain files, or use my project here as a reference for just outputing .png images.




回答9:


I have used MsAgl and it is pretty good. It also has viewers for both WinForms and WPF which may or may not be important to you. One does not have to use the viewers as they are quite loosely coupled to the graph layout engine.

It does not support everything that Graphviz does (notably in terms of some shape types). Also the documentation could be better but it is pretty solid if not the most polished MS product ever.

It does tick all of the items you mention as requirements, though the "on viewer" re-organization merely supports drag-moving nodes, re-routing edges and re-positioning labels. The graph does not respond to the movements of these elements by repositioning any other items.




回答10:


I have used this http://www.codeproject.com/Articles/484616/MVVM-Diagram-Designer it's an open source one, really easy to use. the code is explained really well.




回答11:


Its not .NET, but an often referenced toolkit for rendering graphs is AT&T Graphviz. I've only used the free-standing applications myself, but the source code is available under something resembling an open source license.

Graphviz is used by the popular code documentation tool doxygen to automatically draw various diagrams for its generated documentation.




回答12:


When I did some work involving graphs last summer I found the best option that wasn't overly expensive was to manually do it in SVG, i.e. write out an SVG file from a bunch of strings, and render that out to an image using Inkscape.

This is not a quick and easy solution, but it does allow for near-infinite customisation, so it might be nice if you have to organise the graphs or do spatial organisation based on connections etc.




回答13:


Northwoods offers a pure .NET solution in their GoLayout product. They offer tree, force directed, and layered digraph (which is not quite a Sujiyama effect, but not too far off for many if not most data sets). At $1790/seat it's expensive. There are also some limitations: most importantly, their implementations are designed for "human readable" graphs. I've given it data sets of over 5,000 nodes and had no issue, but I can also generate data sets of less than 500 nodes that cause it to have a stack overflow (recursing too deep). Depending upon your domain, it may (or may not) be a good fit. If you need a general layout package that handles any data set, I'd suggest GraphViz over Northwoods.

I have yet to use any of their WPF capabilities, but I know they have them. I've been using their stuff in WinForms land for a while.




回答14:


I have been playing on GLEE/MSAGL and the actual layout per se is good enough for what I need however I'd like to be able to have more control over what is actually inside the nodes rather than just a single value like now.

For example I'd like to have "details" that are hidden until I click on an expander in the node, or double click the node or hover with the mouse.

Assuming GLEE cannot do this are there now any pure .NET solutions available that could do it?



来源:https://stackoverflow.com/questions/589900/what-options-are-available-for-the-layout-of-directed-or-undirected-graphs-in-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!