Package networkx :: Package drawing :: Module nx_pydot
[hide private]
[frames] | no frames]

Module nx_pydot

source code

Import and export NetworkX graphs in Graphviz dot format using pydot.

Provides:

Either this module or nx_pygraphviz can be used to interface with graphviz.

References:



Author: Aric Hagberg (hagberg@lanl.gov)

Functions [hide private]
 
write_dot(G, path)
Write NetworkX graph G to Graphviz dot format on path.
source code
 
read_dot(path)
Return a NetworkX Graph or DiGraph from a dot file on path.
source code
 
from_pydot(P)
Return a NetworkX XGraph or XDiGraph from a pydot graph.
source code
 
to_pydot(N, graph_attr=None, node_attr=None, edge_attr=None, strict=True)
Return a pydot graph from a NetworkX graph N.
source code
 
pydot_from_networkx(N)
Creates a pydot graph from an networkx graph N
source code
 
networkx_from_pydot(D, create_using=None)
Creates an networkx graph from an pydot graph D
source code
 
graphviz_layout(G, prog='neato', root=None, **kwds)
Create layout using pydot and graphviz.
source code
 
pydot_layout(G, prog='neato', root=None, **kwds)
Create layout using pydot and graphviz.
source code
 
_test_suite() source code
Function Details [hide private]

write_dot(G, path)

source code 

Write NetworkX graph G to Graphviz dot format on path.

Path can be a string or a file handle.

read_dot(path)

source code 

Return a NetworkX Graph or DiGraph from a dot file on path.

Path can be a string or a file handle.

from_pydot(P)

source code 

Return a NetworkX XGraph or XDiGraph from a pydot graph.

>>> X=from_pydot(P)

The XGraph X will have a dictionary X.graph_attr containing the default graphviz attributes for graphs, nodes and edges.

Default node attributes will be in the dictionary X.node_attr which is keyed by node.

Edge attributes will be returned as edge data in the graph X.

If you want a Graph with no attributes attached instead of an XGraph with attributes use

>>> G=Graph(X)

Similarly to make a DiGraph from an XDiGraph

>>> D=DiGraph(X)

to_pydot(N, graph_attr=None, node_attr=None, edge_attr=None, strict=True)

source code 

Return a pydot graph from a NetworkX graph N.

If N is a Graph or DiGraph, graphviz attributes can be supplied through the keyword arguments

graph_attr: dictionary with default attributes for graph, nodes, and edges
keyed by 'graph', 'node', and 'edge' to attribute dictionaries

node_attr: dictionary keyed by node to node attribute dictionary

edge_attr: dictionary keyed by edge tuple to edge attribute dictionary

If N is an XGraph or XDiGraph an attempt will be made first to copy properties attached to the graph (see from_pydot) and then updated with the calling arguments, if any.

graphviz_layout(G, prog='neato', root=None, **kwds)

source code 

Create layout using pydot and graphviz. Returns a dictionary of positions keyed by node.

>>> pos=graphviz_layout(G)
>>> pos=graphviz_layout(G,prog='dot')

This is a wrapper for pydot_layout.

pydot_layout(G, prog='neato', root=None, **kwds)

source code 

Create layout using pydot and graphviz. Returns a dictionary of positions keyed by node.

>>> pos=pydot_layout(G)
>>> pos=pydot_layout(G,prog='dot')