Pygraphviz
Pygraphviz
Release 1.6
PyGraphviz Developers
1 Download 1
1.1 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Installing 3
2.1 Quick Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Installing from Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Tutorial 7
3.1 Start-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Nodes, and edges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 Layout and Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Reference 11
4.1 AGraph Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 API Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4 News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.5 Related Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.6 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.7 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.8 Legal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5 Examples 29
5.1 Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.2 Star . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.3 Miles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Index 31
i
ii
CHAPTER
ONE
DOWNLOAD
1.1 Software
1.2 Documentation
PDF
http://pygraphviz.github.io/documentation/latest/pygraphviz.pdf
1
PyGraphviz Documentation, Release 1.6
2 Chapter 1. Download
CHAPTER
TWO
INSTALLING
and an attempt will be made to find and install an appropriate version that matches your operating system
and Python version.
You can install the development version (at github.com) with:
We tried our best to discover graphviz location automatically, but if you would like specify specific location
for graphviz you may provide additrional parameters to specify graphviz location
include-path= path to graphviz include files library-path= path to graphviz library files
For example
You can install from source by downloading a source archive file (tar.gz or zip) or by checking out the
source files from the Subversion repository.
3
PyGraphviz Documentation, Release 1.6
2.2.2 Github
If you didn’t install in the standard Python site-packages directory you will need to set your PYTHONPATH
variable to the alternate location. Seehttp://docs.python.org/2/install/index.html#search-path for further
details.
2.3 Requirements
2.3.1 Python
PyGraphviz is tested and works with Python 3.6, 3.7, and 3.8.
There are several other distributions that contain the key packages you need for scientific computing. See
the following link for a list: http://scipy.org/install.html
For Red Hat Enterprise Linux 7, the requirements are:
4 Chapter 2. Installing
PyGraphviz Documentation, Release 1.6
2.3.2 GraphViz
To use PyGraphviz you need GraphViz version 2.16 or later. Some versions have known bugs that have
been fixed; get the latest release available for best results.
• Official site: http://www.graphviz.org
2.3. Requirements 5
PyGraphviz Documentation, Release 1.6
6 Chapter 2. Installing
CHAPTER
THREE
TUTORIAL
The API is very similar to that of NetworkX. Much of the NetworkX tutorial at http://networkx.
github.io/documentation/latest/tutorial/ is applicable to PyGraphviz. See http://pygraphviz.github.io/
documentation/latest/reference/api_notes.html for major differences.
3.1 Start-up
3.2 Graphs
>>> G=pgv.AGraph()
You can use the strict and directed keywords to control what type of graph you want. The default is to
create a strict graph (no parallel edges or self-loops). To create a digraph with possible parallel edges and
self-loops use
>>> G=pgv.AGraph(strict=False,directed=True)
>>> G=pgv.AGraph("Petersen.dot")
>>> d={'1': {'2': None}, '2': {'1': None, '3': None}, '3': {'2': None}}
>>> A=pgv.AGraph(d)
7
PyGraphviz Documentation, Release 1.6
>>> h=A.handle
>>> C=pgv.AGraph(h)
>>> nodelist=['f','g','h']
>>> G.add_nodes_from(nodelist)
3.4 Attributes
To set the default attributes for graphs, nodes, and edges use the graph_attr, node_attr, and edge_attr
dictionaries
>>> G=pgv.AGraph(ranksep='0.1')
>>> n=G.get_node(1)
>>> n.attr['shape']='box'
>>> e=G.get_edge('b','c')
>>> e.attr['color']='green'
8 Chapter 3. Tutorial
PyGraphviz Documentation, Release 1.6
>>> s=G.string()
>>> G.write("file.dot")
10 Chapter 3. Tutorial
CHAPTER
FOUR
REFERENCE
Graphviz graph keyword parameters are processed so you may add them like
>>> G=AGraph(landscape='true',ranksep='0.1')
or alternatively
>>> G=AGraph()
>>> G.graph_attr.update(landscape='true',ranksep='0.1')
and
>>> G.node_attr.update(color='red')
>>> G.edge_attr.update(len='2.0',color='blue')
>>> d={'1': {'2': None}, '2': {'1': None, '3': None}, '3': {'2': None}}
>>> A=AGraph(d)
>>> s=A.to_string()
>>> B=AGraph(s)
>>> h=B.handle
>>> C=AGraph(h)
Parameters:
11
PyGraphviz Documentation, Release 1.6
directed: True|False
acyclic(args='', copy=False)
Reverse sufficient edges in digraph to make graph acyclic. Modifies existing graph.
To create a new graph use
>>> A=AGraph()
>>> B=A.acyclic(copy=True)
>>> G=AGraph()
>>> G.add_edge('a','b')
>>> G.edges()
[(u'a', u'b')]
The optional key argument allows assignment of a key to the edge. This is especially useful to
distinguish between parallel edges in multi-edge graphs (strict=False).
>>> G=AGraph(strict=False)
>>> G.add_edge('a','b','first')
>>> G.add_edge('a','b','second')
>>> sorted(G.edges(keys=True))
[(u'a', u'b', u'first'), (u'a', u'b', u'second')]
Attributes can be added when edges are created or updated after creation
>>> G.add_edge('a','b',color='green')
12 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
>>> G=AGraph()
>>> elist=[('a','b'),('b','c')]
>>> G.add_edges_from(elist)
Attributes can be added when edges are created or updated after creation
add_node(n, **attr)
Add a single node n.
If n is not a string, conversion to a string will be attempted. String conversion will work if n has
valid string representation (try str(n) if you are unsure).
>>> G=AGraph()
>>> G.add_node('a')
>>> G.nodes()
[u'a']
>>> G.add_node(1) # will be converted to a string
>>> G.nodes()
[u'a', u'1']
Attributes can be added to nodes on creation or updated after creation (attribute values must be
strings)
>>> G.add_node(2,color='red')
>>> G=AGraph()
>>> nlist=['a','b',1,'spam']
>>> G.add_nodes_from(nlist)
>>> sorted(G.nodes())
[u'1', u'a', u'b', u'spam']
add_path(nlist)
Add the path of nodes given in nlist.
add_subgraph(nbunch=None, name=None, **attr)
Return subgraph induced by nodes in nbunch.
clear()
Remove all nodes, edges, and attributes from the graph.
close()
copy()
Return a copy of the graph.
degree(nbunch=None, with_labels=False)
Return the degree of nodes given in nbunch container.
Using optional with_labels=True returns a dictionary keyed by node with value set to the degree.
degree_iter(nbunch=None, indeg=True, outdeg=True)
Return an iterator over the degree of the nodes given in nbunch container.
Returns paris of (node,degree).
delete_edge(u, v=None, key=None)
Remove edge between nodes u and v from the graph.
With optional key argument will only remove an edge matching (u,v,key).
delete_edges_from(ebunch)
Remove edges from ebunch (a container of edges).
delete_node(n)
Remove the single node n.
Attempting to remove a node that isn’t in the graph will produce an error.
>>> G=AGraph()
>>> G.add_node('a')
>>> G.remove_node('a')
delete_nodes_from(nbunch)
Remove nodes from a container nbunch.
nbunch can be any iterable container such as a list or dictionary
>>> G=AGraph()
>>> nlist=['a','b',1,'spam']
>>> G.add_nodes_from(nlist)
>>> G.remove_nodes_from(nlist)
delete_subgraph(name)
Remove subgraph with given name.
property directed
Return True if graph is directed or False if not.
draw(path=None, format=None, prog=None, args='')
Output graph to path in specified format.
An attempt will be made to guess the output format based on the file extension of path. If that
fails, then the format parameter will be used.
Note, if path is a file object returned by a call to os.fdopen(), then the method for discovering the
format will not work. In such cases, one should explicitly set the format parameter; otherwise, it
will default to ‘dot’.
Formats (not all may be available on every system depending on how Graphviz was built)
‘canon’, ‘cmap’, ‘cmapx’, ‘cmapx_np’, ‘dia’, ‘dot’, ‘fig’, ‘gd’, ‘gd2’, ‘gif’, ‘hpgl’, ‘imap’,
‘imap_np’, ‘ismap’, ‘jpe’, ‘jpeg’, ‘jpg’, ‘mif’, ‘mp’, ‘pcl’, ‘pdf’, ‘pic’, ‘plain’, ‘plain-ext’,
‘png’, ‘ps’, ‘ps2’, ‘svg’, ‘svgz’, ‘vml’, ‘vmlz’, ‘vrml’, ‘vtx’, ‘wbmp’, ‘xdot’, ‘xlib’
If prog is not specified and the graph has positions (see layout()) then no additional graph posi-
tioning will be performed.
14 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
>>> G = AGraph()
>>> G.layout()
>>> G=AGraph()
>>> G.add_edge('a','b')
>>> G.add_edge('c','d')
>>> print(sorted(G.edges()))
[(u'a', u'b'), (u'c', u'd')]
>>> print(G.edges('a'))
[(u'a', u'b')]
edges_iter(nbunch=None, keys=False)
Return iterator over edges in the graph.
If the optional nbunch (container of nodes) only edges adjacent to nodes in nbunch will be re-
turned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use edges() as an alternative.
from_string(string)
Load a graph from a string in dot format.
Overwrites any existing graph.
To make a new graph from a string use
get_edge(u, v, key=None)
Return an edge object (Edge) corresponding to edge (u,v).
>>> G=AGraph()
>>> G.add_edge('a','b')
>>> edge=G.get_edge('a','b')
>>> print(edge)
(u'a', u'b')
With optional key argument will only get edge matching (u,v,key).
get_name()
get_node(n)
Return a node object (Node) corresponding to node n.
>>> G=AGraph()
>>> G.add_node('a')
>>> node=G.get_node('a')
>>> print(node)
a
get_subgraph(name)
Return existing subgraph with specified name or None if it doesn’t exist.
has_edge(u, v=None, key=None)
Return True an edge u-v is in the graph or False if not.
>>> G=AGraph()
>>> G.add_edge('a','b')
>>> G.has_edge('a','b')
True
>>> G=AGraph()
>>> G.add_edge('a','b')
>>> G.has_neighbor('a','b')
True
>>> G=AGraph()
>>> G.add_node('a')
>>> G.has_node('a')
True
>>> 'a' in G # same as G.has_node('a')
True
in_degree(nbunch=None, with_labels=False)
Return the in-degree of nodes given in nbunch container.
Using optional with_labels=True returns a dictionary keyed by node with value set to the degree.
in_degree_iter(nbunch=None)
Return an iterator over the in-degree of the nodes given in nbunch container.
Returns paris of (node,degree).
in_edges(nbunch=None, keys=False)
Return list of in edges in the graph. If the optional nbunch (container of nodes) only in edges
adjacent to nodes in nbunch will be returned.
in_edges_iter(nbunch=None, keys=False)
Return iterator over out edges in the graph.
16 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be
returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use in_edges() as an alternative.
in_neighbors(n)
Return list of predecessor nodes of n.
is_directed()
Return True if graph is directed or False if not.
is_strict()
Return True if graph is strict or False if not.
Strict graphs do not allow parallel edges or self loops.
is_undirected()
Return True if graph is undirected or False if not.
iterdegree(nbunch=None, indeg=True, outdeg=True)
Return an iterator over the degree of the nodes given in nbunch container.
Returns paris of (node,degree).
iteredges(nbunch=None, keys=False)
Return iterator over edges in the graph.
If the optional nbunch (container of nodes) only edges adjacent to nodes in nbunch will be re-
turned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use edges() as an alternative.
iterindegree(nbunch=None)
Return an iterator over the in-degree of the nodes given in nbunch container.
Returns paris of (node,degree).
iterinedges(nbunch=None, keys=False)
Return iterator over out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be
returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use in_edges() as an alternative.
iterneighbors(n)
Return iterator over the nodes attached to n.
Note: modifying the graph structure while iterating over node neighbors may produce unpre-
dictable results. Use neighbors() as an alternative.
iternodes()
Return an iterator over all the nodes in the graph.
Note: modifying the graph structure while iterating over the nodes may produce unpredictable
results. Use nodes() as an alternative.
iteroutdegree(nbunch=None)
Return an iterator over the out-degree of the nodes given in nbunch container.
Returns paris of (node,degree).
iteroutedges(nbunch=None, keys=False)
Return iterator over out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be
returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use out_edges() as an alternative.
iterpred(n)
Return iterator over predecessor nodes of n.
Note: modifying the graph structure while iterating over node predecessors may produce un-
predictable results. Use predecessors() as an alternative.
itersucc(n)
Return iterator over successor nodes of n.
Note: modifying the graph structure while iterating over node successors may produce unpre-
dictable results. Use successors() as an alternative.
layout(prog='neato', args='')
Assign positions to nodes in graph.
Optional prog=[‘neato’|’dot’|’twopi’|’circo’|’fdp’|’nop’] will use specified graphviz layout
method.
>>> A=AGraph()
>>> A.layout() # uses neato
>>> A.layout(prog='dot')
18 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
out_degree(nbunch=None, with_labels=False)
Return the out-degree of nodes given in nbunch container.
Using optional with_labels=True returns a dictionary keyed by node with value set to the degree.
out_degree_iter(nbunch=None)
Return an iterator over the out-degree of the nodes given in nbunch container.
Returns paris of (node,degree).
out_edges(nbunch=None, keys=False)
Return list of out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be
returned.
out_edges_iter(nbunch=None, keys=False)
Return iterator over out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be
returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable re-
sults. Use out_edges() as an alternative.
out_neighbors(n)
Return list of successor nodes of n.
predecessors(n)
Return list of predecessor nodes of n.
predecessors_iter(n)
Return iterator over predecessor nodes of n.
Note: modifying the graph structure while iterating over node predecessors may produce un-
predictable results. Use predecessors() as an alternative.
prepare_nbunch(nbunch=None)
read(path)
Read graph from dot format file on path.
path can be a file name or file handle
use:
G.read('file.dot')
>>> G=AGraph()
>>> G.add_node('a')
>>> G.remove_node('a')
remove_nodes_from(nbunch)
Remove nodes from a container nbunch.
nbunch can be any iterable container such as a list or dictionary
>>> G=AGraph()
>>> nlist=['a','b',1,'spam']
>>> G.add_nodes_from(nlist)
>>> G.remove_nodes_from(nlist)
remove_subgraph(name)
Remove subgraph with given name.
reverse()
Return copy of directed graph with edge directions reversed.
property strict
Return True if graph is strict or False if not.
Strict graphs do not allow parallel edges or self loops.
string()
Return a string (unicode) representation of graph in dot format.
string_nop()
Return a string (unicode) representation of graph in dot format.
subgraph(nbunch=None, name=None, **attr)
Return subgraph induced by nodes in nbunch.
subgraph_parent(nbunch=None, name=None)
Return parent graph of subgraph or None if graph is root graph.
subgraph_root(nbunch=None, name=None)
Return root graph of subgraph or None if graph is root graph.
subgraphs()
Return a list of all subgraphs in the graph.
subgraphs_iter()
Iterator over subgraphs.
successors(n)
Return list of successor nodes of n.
successors_iter(n)
Return iterator over successor nodes of n.
Note: modifying the graph structure while iterating over node successors may produce unpre-
dictable results. Use successors() as an alternative.
to_directed(**kwds)
Return directed copy of graph.
Each undirected edge u-v is represented as two directed edges u->v and v->u.
to_string()
Return a string (unicode) representation of graph in dot format.
to_undirected()
Return undirected copy of graph.
tred(args='', copy=False)
Transitive reduction of graph. Modifies existing graph.
20 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
>>> A=AGraph()
>>> B=A.tred(copy=True)
>>> A = AGraph()
>>> A_unflattened = A.unflatten('-f -l 3')
>>> A.unflatten('-f -l 1').layout()
G.write('file.dot')
4.2 FAQ
I get an error like ImportError: libagraph.so.1: cannot open shared object file: No
such file or directory
What is wrong?
A Some Unix systems don’t include the Graphviz library in the default search path
for the run-time linker. The path is often something like /usr/lib/graphviz or
/sw/lib/graphviz etc. and it needs to be added to your search path. You can
1. set the LD_LIBRARY_PATH environment variable e.g. export
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/graphviz
2. configure your system with the additional path. e.g. for Linux add a line to
/etc/ld.so.conf and run ldconfig
Q How do I compile pygraphviz under Windows? And why don’t you distribute a
pygraphviz Windows installer?
A We don’t have Windows development machines but would like to have py-
graphviz work on all platforms. If you have success with Windows or would
be willing to help test and distribute a Windows installer please drop us a note.
See also issues at: https://github.com/pygraphviz/pygraphviz/search?q=
Windows&type=Issues
4.2. FAQ 21
PyGraphviz Documentation, Release 1.6
4.3.1 pygraphviz-1.2
No API changes
4.3.2 pygraphviz-1.1
Pygraphviz-1.1 adds unicode (graphviz charset) support. The default Node type is now uni-
code. See examples/utf8.py for an example of how to use non-ASCII characters.
The __str__ and __repr__ methods have been rewritten and a __unicode__ method added.
If G is a pygraphviz.AGraph object then
• str(G) produces a dot-format string representation (some characters might not be repre-
sented correctly)
• unicode(G) produces a dot-format unicode representation
• repr(G) produces a string of the unicode representation.
• print G produces a formatted dot language output
4.3.3 pygraphivz-0.32
pygraphviz-0.32 is a rewrite of pygraphviz-0.2x with some significant changes in the API and
Graphviz wrapper. It is not compatible with with earlier versions.
The goal of pygraphviz is to provide a (mostly) Pythonic interface to the Graphviz Agraph data-
structure, layout, and drawing algorithms.
The API is now similar to the NetworkX API. Studying the documentation and Tutorial for Net-
workX will teach you most of what you need to know for pygraphviz. For a short introduction
on pygraphviz see the pygraphviz Tutorial.
There are some important differences between the PyGraphviz and NetworkX API. With Py-
Graphviz
• All nodes must be of string or unicode type. An attempt will be made to convert other
types to a string.
• Nodes and edges are custom Python objects. Nodes are like unicode/string objects and
edges are like tuple objects. (In NetworkX nodes can be anything and edges are two- or
three-tuples.)
• Graphs, edges, and nodes may have attributes such as color, size, shape, attached to them.
If the attributes are known Graphviz attributes they will be used for drawing and layout.
• The layout() and draw() methods allow positioning of nodes and rendering in all of the
supported Graphviz output formats.
• The string() method produces a string with the graph represented in Graphviz dot format.
See also from_string().
• The subgraph() method is the Graphviz representation of subgraphs: a tree of graphs under
the original (root) graph. The are primarily used for clustering of nodes when drawing with
dot.
22 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
4.4 News
4.4.1 pygraphviz-1.6
4.4.2 pygraphviz-1.5
4.4.3 pygraphviz-1.3.1
4.4.4 pygraphviz-1.3
4.4.5 pygraphviz-1.2
4.4. News 23
PyGraphviz Documentation, Release 1.6
4.4.6 pygraphviz-1.1
4.4.7 pygraphviz-1.0.0
4.4.8 pygraphviz-0.99.1
24 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
4.4.9 pygraphviz-0.99
4.4.10 pygraphviz-0.37
4.4.11 pygraphviz-0.36
4.4.12 pygraphviz-0.35
4.4. News 25
PyGraphviz Documentation, Release 1.6
4.4.13 pygraphviz-0.34
4.4.14 pygraphviz-0.33
• Workaround for “nop” bug in graphviz-2.8, improved packaging, updated swig wrapper, better error
handling.
4.4.15 pygraphviz-0.32
The release pygraphviz-0.32 is the second rewrite of the original project. It has improved at-
tribute handling and drawing capabilities. It is not backward compatible with earlier versions.
Earlier versions will always be available at the download site.
This version now inter-operates with many of the NetworkX algorithms and graph
generators. See https://networkx.lanl.gov/trac/browser/networkx/trunk/doc/examples/
pygraphviz_simple.py
4.6 History
The original concept was developed and implemented by Manos Renieris at Brown University:
http://www.cs.brown.edu/~er/software/
26 Chapter 4. Reference
PyGraphviz Documentation, Release 1.6
4.7 Credits
Thanks to Stephen North and the AT&T Graphviz team for creating and maintaining the Graphviz graph
layout and drawing packages
Thanks to Manos Renieris for the original idea.
Thanks to the following people who have made contributions:
• Cyril Brulebois helped clean up the packaging for Debian and find bugs.
• Rene Hogendoorn developed the threads code to provide nonblocking, multiplatform IO.
• Ross Richardson suggested fixes and tested the attribute handling.
• Alexis Dinno debugged the setup and installation for OSX.
• Stefano Costa reported attribute bugs and contributed the code to run Graphviz “tred” and friends.
• Casey Deccio contributed unicode handling design and code.
4.8 Legal
4.7. Credits 27
PyGraphviz Documentation, Release 1.6
4.8.2 Notice
This software and ancillary information (herein called SOFTWARE ) called pygraphviz is made
available under the terms described here. The SOFTWARE has been approved for release with
associated LA-CC number 04-073.
Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees
of the University of California, operator of the Los Alamos National Laboratory under Con-
tract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights
to use, reproduce, and distribute this SOFTWARE. The public may copy, distribute, prepare
derivative works and publicly display this SOFTWARE without charge, provided that this No-
tice and any statement of authorship are reproduced on all copies. Neither the Government nor
the University makes any warranty, express or implied, or assumes any liability or responsibility
for the use of this SOFTWARE.
If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be
clearly marked, so as not to confuse it with the version available from Los Alamos National
Laboratory.
28 Chapter 4. Reference
CHAPTER
FIVE
EXAMPLES
5.1 Simple
A basic example showing how to read and write dot files and draw graphs.
http://github.com/pygraphviz/pygraphviz/tree/master/examples/simple.py
5.2 Star
5.3 Miles
An example showing how to use Graphviz to draw a graph with given positions.
http://github.com/pygraphviz/pygraphviz/tree/master/examples/miles.py
29
PyGraphviz Documentation, Release 1.6
30 Chapter 5. Examples
INDEX
31
PyGraphviz Documentation, Release 1.6
P
predecessors() (AGraph method), 19
predecessors_iter() (AGraph method), 19
prepare_nbunch() (AGraph method), 19
R
read() (AGraph method), 19
remove_edge() (AGraph method), 19
remove_edges_from() (AGraph method), 19
remove_node() (AGraph method), 19
remove_nodes_from() (AGraph method), 19
remove_subgraph() (AGraph method), 20
reverse() (AGraph method), 20
S
strict() (AGraph property), 20
string() (AGraph method), 20
string_nop() (AGraph method), 20
subgraph() (AGraph method), 20
subgraph_parent() (AGraph method), 20
subgraph_root() (AGraph method), 20
subgraphs() (AGraph method), 20
subgraphs_iter() (AGraph method), 20
successors() (AGraph method), 20
successors_iter() (AGraph method), 20
T
to_directed() (AGraph method), 20
to_string() (AGraph method), 20
to_undirected() (AGraph method), 20
tred() (AGraph method), 20
U
unflatten() (AGraph method), 21
W
write() (AGraph method), 21
32 Index