Resize and drag vertices

Nov 17, 2012 at 9:49 AM

Hi all

I'm using Graphviz4Net for a while now and it works pretty nice! Altough I need some other features in the graph. Maybe someone has an idea or can tell me how to accomplish all this in an easy way. (I'm not sure whether this functionality already exists in the given source code or is easily added :-))

What I want to do is:

  • Resize vertices and keep the given sizes when the graph is relayoutet
  • Drag/Pan the vertices and keep the new positions when the graph gets relayoutet

(The user can interact with the graph on a touchscreen and should be able to enlarge/downsize vertices as well should be able to put vertices where he wants)

Can you give me some advice? Would be great!

Thanks in advance ;-)

Chris

Coordinator
Nov 17, 2012 at 10:35 AM

Hi Chris,

the problem here is that Graphviz4Net uses an external tool to do the layouting, so i am not sure whether it will have a decent performance if you do the re-layouting online on every resize/move, but you can certainly try.

Technically what you would need is to add some more data into the input for dot.exe.

Resizing: size of a vertex as an input for dot.exe is calculated in ILayoutBuilder.GetSize(vertex), this is for WPF implemented in WPFLayoutBuilder that calculates the size by asking WPF about the size of the corresponding control. You can either override this method and make the size bigger where you need, or maybe all you need is just to set the size of the WPF controls by hand, this will be then propagated into the result of the original GetSize implementation that asks WPF about the size.

Dragging: one can specify positions of certain nodes in an input for dot.exe, the problem is that then, the other nodes will probably be moved somewhere else. You can also specify position for all nodes and then dot.exe will just figure out how to layout edges, maybe that's a viable solution. However, Graphviz4Net is not prepared for this scenario. I can think of a method, say, GetPosition(node) in ILayoutBuilder that would return null for nodes that don't want to have a certain position and some position for those who do want to have specific position. Then this would be written into the input for dot.exe in a same way as size is.

Hope that helps,
Steve 

Coordinator
Nov 17, 2012 at 10:38 AM

You can also take a look at Grap#. AFAIK they don't have curved edges and subgraphs, but they have better support for online editing (dragging, resizing, etc.) of the already layouted and rendered graph.