Microsoft Automatic Graph Layout

Established: December 5, 2007

MSAGL is a .NET tool for graph layout and viewing. It was developed in Microsoft by Lev Nachmanson, Sergey Pupyrev, Tim Dwyer and Ted Hart. MSAGL is available as open source here.

All samples use the C# language.

The Distribution Content and Important Features

The package contains the following:

  • Layout engine (Microsoft.MSAGL.dll) – The core layout functionality. This component can be used directly in cases when visualization is handled by a tool other than MSAGL.
  • Drawing module (Microsoft.MSAGL.Drawing.dll) – The 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.
  • Viewer control (Microsoft.MSAGL.GraphViewerGDIGraph.dll) – The viewer control, and some other rendering functionality.

Some important features of the viewer are:

  • Pan and Zoom of the graph.
  • Forward and Backward navigation.
  • Ability to configure tooltips and highlighting of graph entities.
  • Ability to search for and focus on entities of the graph.
  • Do I have control over node positions? Can I request that two nodes should be in the same layer?

    This feature has not been implemented yet.

    Can a layout be edited by using the viewer?

    Yes, see sample Editing.

    I have a graph with sub-graphs. Can you layout a graph taking into account sub-graphs and drawing a bounding box around each sub-graph?

    This feature has not been implemented.

    What is the maximal size of a graph that MSAGL can handle?

    Theoretically, there is no limit. In practice, MSAGL is not designed to handle huge graphs. Some MSAGL users were successful in laying out and viewing graphs with 15000 edges. They were doing it on a machine with 4G of RAM, and the waiting time was about 10 minutes. By switching LayoutSettings of the graph to MdsLayoutSettings or RankingLayoutSettings a graph with 50000 elements and more can be processed in a reasonable time.

    Can I specify a custom brush for node drawing?

    Yes, it can be done by overriding node rendering. See sample NodesWithImages showing how to override node rendering.

    Can I set a node label different from its ID?

    Yes, use node.Attr.Label.

    I need to render a graph on a WEB page. Can MSAGL help here?

    Sure. Class Microsoft.Msagl.GraphViewerGDI.GraphRenderer serves this purpose. It can render a graph using just a Graphics object. The only think you need to do is to create a Graphics object and pass it to method Render. See the “Code Sample” tab below for an example.

    Can I associate my data with a node or an edge of the graph?

    Use field UserData of Node or Edge.

    Where can I read a description of how MSAGL works?

    There is a technical report explaining the theory behind the tool.



Portrait of Lev Nachmanson

Lev Nachmanson

Principal Research Software Development Engineer