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

Module nx_agraph

source code

Interface to pygraphviz AGraph class.

Usage

>>> from networkx import *
>>> G=complete_graph(5)
>>> A=to_agraph(G)
>>> H=from_agraph(A)



Author: Aric Hagberg (hagberg@lanl.gov)

Functions [hide private]
 
from_agraph(A, create_using=None)
Return a NetworkX XGraph or XDiGraph from a pygraphviz graph.
source code
 
to_agraph(N, graph_attr=None, node_attr=None, edge_attr=None, strict=True)
Return a pygraphviz graph from a NetworkX graph N.
source code
 
write_dot(G, path)
Write NetworkX graph G to Graphviz dot format on path.
source code
 
read_dot(path, create_using=None)
Return a NetworkX XGraph or XdiGraph from a dot file on path.
source code
 
graphviz_layout(G, prog='neato', root=None, args='')
Create layout using graphviz.
source code
 
pygraphviz_layout(G, prog='neato', root=None, args='')
Create layout using pygraphviz and graphviz.
source code
 
_test_suite() source code
Function Details [hide private]

from_agraph(A, create_using=None)

source code 

Return a NetworkX XGraph or XDiGraph from a pygraphviz graph.

>>> X=from_agraph(A)

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)

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

source code 

Return a pygraphviz graph from a NetworkX graph N.

If N is a Graph or DiGraph, graphviz attributes can be supplied through the 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_agraph) and then updated with the calling arguments if any.

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, create_using=None)

source code 

Return a NetworkX XGraph or XdiGraph from a dot file on path.

Path can be a string or a file handle.

graphviz_layout(G, prog='neato', root=None, args='')

source code 

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

>>> from networkx import *
>>> G=petersen_graph()
>>> pos=graphviz_layout(G)
>>> pos=graphviz_layout(G,prog='dot')

This is a wrapper for pygraphviz_layout.

pygraphviz_layout(G, prog='neato', root=None, args='')

source code 

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

>>> from networkx import *
>>> G=petersen_graph()
>>> pos=pygraphviz_layout(G)
>>> pos=pygraphviz_layout(G,prog='dot')