This project is read-only.

Creating a custom graph layout algorithm

Oct 17, 2012 at 3:30 PM

What I want to accomplish is to make a custom graph design, specifying where nodes are drawn in the graph based on some of their properties.

My first Idea for an approach is to either create my own LayoutALgorithmType that behaves as per my wishes or to somehow be able to modify the position for nodes within the graph manually thus creationg my own method for assigning positions for the graph nodes.

I have tried some googeling and some minor trial and error as well using samples from the source code but have so far been unsucessfull in any of my two ideas.

I would greatly appriciate any pointers on how to set positions for nodes or if anyone has some code examples for LayoutALgorithmTypes that would also be greatly apprieciated!

 

Sincerely, Linus Karlsson

Jun 24, 2013 at 9:01 PM
Any updates on this? I need to do something similar.

Unfortunately, I didn't find any answer on all the different question related with this topic. Is there someone providing support on Graph#?

Thanks,
Ezequiel
Jun 24, 2013 at 9:19 PM
Its been a while since I used graph#. Almost as much time as it has bin since I posted my original question. I do remeber somewhat solving the problem though =)

What I ended up doing was som happy hacking using parts of the solution provided by someone on this site for labeling the lines in the graph. What you have to do is first draw the graph and then you should get the drawn object in the layout and get/set its positions. I am sorry that i dont rember exactly how to do this( and since I am no longer working for the company for which I provided that particlar code I cant check it either).

But somthing along the lines of "canvas get position" can be used. But I would advise to check on the nodelabeling and then google get position of objects in theview model.

In my solution I first set up the graph, and the looped through it to get/set positions of the nodes that I wanted to move.

I really hope this helps!
Jun 25, 2013 at 5:11 AM
Edited Jun 25, 2013 at 5:17 AM
Hi! You can manually add VertexControls into the layout and then use GraphCanvas.SetX and GraphCanvas.SetY methods.
Also let me advice you to check the http://graphx.codeplex.com as this is successor of Graph# and supports custom algorithm layouts easily along with the many other features graph# doesn't.
Jun 25, 2013 at 6:47 PM
Thanks both for your answers. I'll take a look at the algorithm Lincarte explains and also to GraphX.

I appreciate it!
Ezequiel