Skip to content

Commit

Permalink
Merge branch 'pydot' into pydot2
Browse files Browse the repository at this point in the history
Incorporating changes introduced in networkx#905.

Conflicts:
	networkx/drawing/nx_pydot.py
  • Loading branch information
chebee7i committed Jul 20, 2013
2 parents b69e138 + 367a820 commit 1fdec5c
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 75 deletions.
1 change: 1 addition & 0 deletions doc/source/reference/drawing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Graphviz with pydot
read_dot
graphviz_layout
pydot_layout
draw_pydot


Graph Layout
Expand Down
37 changes: 36 additions & 1 deletion doc/source/tutorial/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,5 +465,40 @@ and PyGraphviz, or pydot, are available on your system, you can also use
>>> nx.draw_graphviz(G)
>>> nx.write_dot(G,'file.dot')

Details on drawing graphs: :doc:`/reference/drawing`
Drawing graphs with Pydot/Graphviz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If `pydot <http://code.google.com/p/pydot/>`_ and
`Graphviz <http://www.graphviz.org/>`_ are both installed, then graphs can
be 1) converted from NetworkX to the pydot format, 2) drawn externally using
Graphviz, and 3) displayed using the operating system's default graphics
viewer.

The example below constructs a NetworkX graph whose attributes are compatible
with the Graphviz DOT language and then displays the resulting PNG.
Unsupported attributes in NetworkX graphs are silently ignored during the
conversion to a pydot graph. Other output formats are also possible.
For details, consult the function's docstring and the Graphviz documentation.

>>> G = nx.DiGraph()
>>> G.graph['rankdir'] = 'LR'
>>> G.graph['dpi'] = 120
>>> G.add_cycle(range(4))
>>> G.add_node(0, color='red', style='filled', fillcolor='pink')
>>> G.add_node(1, shape='square')
>>> G.add_edge(0, 1, color='red', style='dashed')
>>> G.add_edge(3, 3, label='a')
>>> nx.draw_pydot(G)

If you are working within an IPython Notebook, then this same function can
display the graph inline:

>>> nx.draw_pydot(G, show='ipynb')

To make all graphs displayed inline, a global default value can be modified
(e.g., in the startup file for the profile):

>>> nx.nxParams['pydot_show'] = 'ipynb'

For other details on drawing graphs: :doc:`/reference/drawing`

2 changes: 2 additions & 0 deletions networkx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
__date__ = release.date
__version__ = release.version

from networkx.params import nxParams, reset_params

#These are import orderwise
from networkx.exception import *
import networkx.external
Expand Down
Loading

0 comments on commit 1fdec5c

Please sign in to comment.