MSAGL is a .NET tool for graph layout and viewing. It was developed in Microsoft Research by Lev Nachmanson. MSAGL is built on the principle of the Sugiyama scheme; it produces so called layered, or hierarchical layouts. This kind of a layout naturally applies to graphs with some flow of information. For example, the graph could represent a control flow graph of a program, a state machine, or a C++ class hierarchy.
Purchase
The Microsoft Automatic Graph Layout (MSAGL) tool can be purchased at US online store. For a limited time use promotion code AGLR1 to get Automatic Graph Layout for only $99.95 from the US online store.
The Distribution Content and Important Features
The package contains the following DLLs:
- Microsoft.MSAGL.dll is the layout engine. The core layout functionality is implemented in this DLL. One would directly use Microsoft.MSAGL.dll mainly in cases when visualization is handled by some other tool than MSAGL.
- Microsoft.MSAGL.Drawing.dll contains definitions of different drawing attributes like colors, line styles, etc. It also contains definitions of a node class, an edge class, and a graph class. By using these classes a user can create a graph object and use it later for layout, and rendering.
- Microsoft.MSAGL.GraphViewerGDIGraph.dll contains a viewer control, and provides some other rendering functionality.
The most important features of the viewer are:
- Zoom and pan abilities.
- Event SelectedObjectChanged. A better name for this event would be “AnObjectUnderMouseCursorHasChanged”, but it is a too long name. The event can be used for configuring of the tooltip, and the graph entities highlighting.
- Backward and forward navigation.
- Methods CenterToPoint, CenterToObject, etc can be used for graph entities search.
Code Samples
The code snippet demonstrates the basic usage of the viewer. It uses the C# language.
The Viewer sample
Drawing of the graph from the sample
using System;
using System.Collections.Generic;
using System.Windows.Forms;
class ViewerSample {
public static void Main() {
//create a form
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
//create a viewer object
Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
//create a graph object
Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
//create the graph content
graph.AddEdge("A", "B");
graph.AddEdge("B", "C");
graph.AddEdge("A", "C").EdgeAttr.Color = Microsoft.Msagl.Drawing.Color.Green;
graph.FindNode("A").Attr.Fillcolor = Microsoft.Msagl.Drawing.Color.Magenta;
graph.FindNode("B").Attr.Fillcolor = Microsoft.Msagl.Drawing.Color.MistyRose;
Microsoft.Msagl.Drawing.Node c = graph.FindNode("C");
c.Attr.Fillcolor = Microsoft.Msagl.Drawing.Color.PaleGreen;
c.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;
//bind the graph to the viewer
viewer.Graph = graph;
//associate the viewer with the form
form.SuspendLayout();
viewer.Dock = System.Windows.Forms.DockStyle.Fill;
form.Controls.Add(viewer);
form.ResumeLayout();
//show the form
form.ShowDialog();
}
}
Layouts Created by MSAGL







