Programmatically change the layout algorithm
-
Monday, October 05, 2009 8:59 PMHi,
The default layout algorithm is not well suited to the kinds of graphs I'm drawing and I wonder how I would go about changing to one of the alternate layout methods in code. I am rendering to a bitmap so interacting with the viewer is not an option.
thanks for the great tool,
R
All Replies
-
Tuesday, October 06, 2009 10:41 PMOwnerAt the moment GraphRenderer will alway use the Sugiyama layout. It is a bug. To work around it
please change the CalculateLayout method of GraphRenderer in the following way
public void CalculateLayout() {
using (GViewer gv = new GViewer()){
gv.CurrentLayoutMethod = LayoutMethod.UseSettingsOfTheGraph;
layedOutGraph = gv.CalculateLayout(this.graph);
}
}
Then before calling GraphRenderer set the graph settings.
graph.LayoutAlgorithmSettings = new Microsoft.Msagl.Mds.MdsLayoutSettings();
Thanks,
Lev
Lev Nachmanson -
Tuesday, December 07, 2010 10:14 PM
To be clear, since GraphRenderer is sealed and the source code doesn't seem to be freely available, you will need to disasseble (I used Red Gate's Reflector) that class. Then copy the code and make your own GraphRenderer with that disassebled source code MAKING sure you change CalculateLayout with the method described above.
- Marked As Answer by Lev NachmansonOwner Monday, May 16, 2011 3:11 AM
- Unmarked As Answer by Lev NachmansonOwner Monday, January 23, 2012 8:58 PM
-
Monday, January 23, 2012 9:05 PMOwner
The source of GraphRenderer is available in the distribution. So please change the source there.
Thanks,
Lev
Lev Nachmanson- Marked As Answer by Lev NachmansonOwner Monday, January 23, 2012 9:05 PM

