[python-uk] Library for (undirected) graphs in Python?

Daniel Pope mauve at mauveweb.co.uk
Tue Jan 25 10:48:40 CET 2011


On 24/01/11 22:29, Alex Willmer wrote:
> The only program I know for (un)directed graphs is Graphviz and
> associated DOT format. For which there a few hits:
> http://pypi.python.org/pypi?:action=search&term=graphviz

You don't need a library to use graphviz. graphviz has a command-line 
interface that renders a DOT file. A DOT file is just a list of nodes 
and edges and how they should be drawn.

At its simplest an undirected graph in DOT format is written like:

graph {
     A -- B;
     B -- C;
     B -- D;
}

This is easy to generate with any version of Python.

Dan


More information about the python-uk mailing list