nx_pydot
========

>>> from networkx import *
>>> from networkx.drawing import *
>>> import os

Undirected
----------

>>> H=Graph()
>>> H.add_edge('A','B')
>>> H.add_edge('A','C')
>>> H.add_edge('B','C')
>>> H.add_edge('A','D')
>>> H.add_node('E')


>>> P=pydot_from_networkx(H)
>>> N=networkx_from_pydot(P)
>>> sorted(N.nodes())==sorted(H.nodes())
True
>>> sorted(N.edges())==sorted(H.edges())
True


>>> import tempfile
>>> fname=tempfile.mktemp()
>>> P.write_raw(fname)
True

>>> Pin=pydot.graph_from_dot_file(fname)   
>>> sorted([p.name for p in P.node_list])==sorted([p.name for p in Pin.node_list])
True
>>> e1=[(e.src,e.dst) for e in P.edge_list]
>>> e2=[(e.src,e.dst) for e in Pin.edge_list]
>>> sorted(e1)==sorted(e2)
True


>>> Hin=read_dot(fname)

>>> os.unlink(fname)

Directed
--------

>>> H=DiGraph()
>>> H.add_edge('A','B')
>>> H.add_edge('A','C')
>>> H.add_edge('B','C')
>>> H.add_edge('A','D')
>>> H.add_node('E')


>>> P=pydot_from_networkx(H)
>>> N=networkx_from_pydot(P)

>>> sorted(N.nodes())==sorted(H.nodes())
True
>>> sorted(N.edges())==sorted(H.edges())
True


>>> import tempfile
>>> fname=tempfile.mktemp()
>>> P.write_raw(fname)
True

>>> Pin=pydot.graph_from_dot_file(fname)   
>>> sorted([p.name for p in P.node_list])==sorted([p.name for p in Pin.node_list])
True
>>> e1=[(e.src,e.dst) for e in P.edge_list]
>>> e2=[(e.src,e.dst) for e in Pin.edge_list]
>>> sorted(e1)==sorted(e2)
True


>>> Hin=read_dot(fname)
>>> sorted(H.nodes())==sorted(Hin.nodes())
True
>>> sorted(H.edges())==sorted(Hin.edges())
True
>>> os.unlink(fname)

>>> fname=tempfile.mktemp()
>>> write_dot(H,fname)
>>> H1=read_dot(fname)
>>> sorted(H.nodes())==sorted(Hin.nodes())
True
>>> sorted(H.edges())==sorted(Hin.edges())
True
>>> os.unlink(fname)
