A library to manage .dot files
There are existing python libraries for this, but they do not always do it correctly (e.g. PyDot does not respect order within a .dot file).
Classes
DictMixin | |
SimpleDot([name, digraph, strict]) | Repsents a graphviz .dot file (also known as .gv). |
Bases: UserDict.DictMixin
Repsents a graphviz .dot file (also known as .gv).
Uses a dictionary-like interface via the :class:~`UserDict.DictMixin` class.
To produce .dot output, cast to string e.g. str(mysimpledot)
Contains three types of graph objects:
These can be set and accessed by standard slice notation (e.g. dot[nodename] = {}).
Node names and subgraph names are unique but multiple parallel edges are permitted. However, slice notation (e.g. dot[(from, to)]) cannot cope with this. Therefore, when there are multiple parallel edges, accessing any of them returns a tuple of all their attributes as dictionaries. To create multiple parallel edges you must use the add() method
Names of nodes and subgraphs, attribute keys, and attribute values should all be graphviz compatible. Some attempt to wrap string attribute values in quotes will be made so that the use of plain python strings is accepted by graphviz.
Very little checking and enforcement is performed. This means that you can use them in ways not originally intended; for example, you can se attributes that no graphviz programme will recognize. But, it also means you can break it by doing odd things to them.
Guaranteed to add the passed key/value to self, even if it is a duplicate.
Returns a tuple of all things matching that key.
Designed for multiple edges, but will also work with single edges, nodes, or subgraphs. This provides a unified interface.
Return a tuple of the keys.