Note: pydot is now hosted in Google Code

This is the page of pydot, a Python interface to Graphviz's Dot language.

Provides:

An interface for creating both directed and non directed graphs from Python. Currently all attributes implemented in the Dot language are supported (up to Graphviz 1.16).

Output can be inlined in Postscript into interactive scientific environments like TeXmacs, or output in any of the format's supported by the Graphviz tools dot, neato, twopi.

Anyone discovering a bug or interested in a certain feature is more than welcome to contact me. E-mail: ero (at) this_domain

Requires:

Changelog:

  • 0.9.1 It should now work on Windows.
  • 0.9.2 And now on MacOS X.
  • 0.9.3b
    • License has been changed from GPL to MIT.
    • Minor bugfixes
    • Now there's support to retrieve Nodes, Edges and Subgraphs and modify their properties, providing more of an interactive experience.
  • 0.9.4 Merged fixes by Ramon Felciano
    • Better handling of default 'node' and 'edge' definitions.
    • Subgraph class now accepts the same parametes as Graph.
  • 0.9.6 Miscellaneous bugfixes.
  • 0.9.9 Added the capability to load DOT files and support for HTML labels.
    • Thanks to the code contributed by Michael Krause, pydot is now able to load DOT files. The loader has been tested against plethora of test DOT files, and the results written to PS files, which ended up being identical to the ones obtained straight through dot. Functions graph_from_dot_file and graph_from_dot_data have been added. Note that if using pyparsing < 1.2 the tabs in labels are converted to whitespaces. 1.2 fixed that.
    • Adrian Heilbut noticed that there was no way of telling pydot to create HTML labels. Starting from this version, if the label's first character is '<' and last is '>', the label will be treated as HTML. If this is not the desired behaviour it suffices with adding a whitespace before the first '<' character or after the last '>'.
  • 0.9.10 Graphs can now be pickled. The parser has been enhaced and should be able to parse almost any dot file.

Limitations/Bugs:

Currently, the only limitation parsing dot files is when labels have escaped double quotes, pyparsing 1.2.2 does not currently handle them properly. Newer versions will.

The complete ChangeLog is available here.

Download:

You can get the latest version (0.9.10) from Google Code.

Installation:

Download the tar.gz and run python setup.py install. That will install the module into your system's main location for Python modules.

Documentation:

I have made an attempt to provide as much documentation within the module as possible. In the following link you can find pydoc output.

pydot documentation

Usage examples:

Most of the time, a Dot instance will be created. Then Node and Edge instances will be added to the Dot instance.

Finally a representation of the graph can be obtained by writing it to a file with write_[format] or obtaining the raw data with create_[format].

import pydot

edges=[(1,2), (1,3), (1,4), (3,4)]
g=pydot.graph_from_edges(edges)
g.write_jpeg('graph_from_edges_dot.jpg', prog='dot')
g.write_jpeg('graph_from_edges_neato.jpg', prog='neato')

Screenshots/Examples:

Graphviz's Python interface and Postscript output from tmPython within TeXmacs.

Graph of the Sasser.D/NetSky.V installation function (CFG). (output through dot).

PDF versions: NetSky.V FTP function and Sasser.D FTP function

Graph of the Sasser.D/NetSky.V FTP function (CFG). (output through dot).

PDF versions: NetSky.V Install function and Sasser.D Install function

Graph of the Mimail.J worm function references (output through dot).

Graph of the Mimail.J worm function references (output through twopi).