Note: This is taken from the original mfGraph page at RealMike's Programming Resources. The text explains my motivation when I started developing mfGraph back in 2003. Since then, my plans for mfGraph have changed somewhat. See the more recent text "About mfGraph Library".
Furthermore, claims I make about shortcomings in Microsoft products might not be true anymore for the current product versions.
The Story Behind
For a long time, I have been looking for a cheap and easy way to draw graphs. Often, in software design or when you're writing documentation, a graph says more than a thousand words1. Drawing simple graphs on a flipchart or on a whiteboard is easy. Reproducing these drawings in Word documents is hard. Word has not the slightest notion of nodes and edges; when you move a node, the "connected" edges stay where they are2.
Commercial solutions exist, but they all have their problems:
Word, Powerpoint, Excel - Commercial, but not a solution. See above.
Visio - Nice but expensive.
Rational Rose - Great for software design, but not every graph-drawing problem is a software design issue.
A GUI-only solution is also not optimal. Using an API or a command-line interface, one should be able to extend one's own programs with graph-drawing capabilities. For example, Doxygen, a popular documentation generator, uses a command-line utility to layout include graphs and inheritance diagrams. The tool that Doxygen uses is DOT from the GraphViz package.
GraphViz is an open-source graph layouting toolkit, developed and maintained by AT&T Research Labs. The command-line utilities take as input a graph description in the custom DOT language and calculate a visually pleasing layout. Supported output formats include JPEG, PNG, PostScript, and many others. For example, this graph description,
digraph { a -> b a -> c b -> x x -> c }
converted by DOT using the command-line
dot.exe -Tpng -ograph2.png
results in the following graph:
Nodes, edges, and subgraphs can have associated attributes to colorize nodes and edges, to apply multi-line labels, to change node shapes, etc. Using the abstract DOT language, graphs of arbitrary complexity can be created in a matter of minutes. Although command-line based, this is easier, faster, and more convenient than what GUI-only solutions could offer.
Note: The GraphViz homepage contains a gallery that really shows off the capabilities of the toolkit.
mfGraph Benefits
The mfGraph Library consists of the following components:
Generic C++ Classes - To manipulate graphs in memory using nodes, edges, and subgraphs, all of which can have associated named attributes. Many uses, independent of GraphViz!
DrawGraph - A derived class for saving and loading graphs in DOT format (loading uses a custom Flex/Bison parser for the DOT language). Can load graphs in XDOT format, which contains basic drawing commands to render graphs on screen.
GraphDrawer - Draws a graph to any GDI device context (including metafile device contexts). Supports zooming and, together with DrawGraph, hit-testing.
TmfGraph - A VCL control to display graphs in Borland C++Builder applications.
A sample application is included that demonstrates how the mfGraph Library can be put to good use in a real-world application.
mfGraph UI Sample Application - A GUI that enables users to draw graphs either by using the mouse or by entering a DOT listing. The resulting graphs can be exported in metafile format so that they can be printed and/or embedded in Word documents. See also the Screenshots section.
The mfGraph Library is distributed under the terms of the GNU Lesser General Public License, so that it can be used in non-free software. The mfGraph UI Sample Application is distributed under the terms of the GNU General Public License.
The Future of mfGraph
My current focus is on integrating mfGraph into wxPython GUI applications. Just like the standard class wxHtmlWindow encapsulates the display of HTML pages, there should once be a class wxMfgraphWindow that displays DOT graphs and that handles all user interaction with the graph. (For Borland C++Builder, a similar visual component is already part of the distribution package.)
Other Software of Interest
KGraphViewer is an Open Source DOT graph viewer for KDE (GNU/Linux). Currently (June 2005) in early stages of development.
The Boost Graph Library (BGL) provides some general purpose C++ graph classes and includes a DOT file parser. The focus of the BGL seems to be on graphs as mathematical abstractions. (The focus of mfGraph is on graphs as colorful pixels. )