~ubuntu-branches/ubuntu/trusty/python-networkx/trusty

« back to all changes in this revision

Viewing changes to networkx/drawing/tests/nx_agraph.txt

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2009-11-23 15:44:34 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091123154434-ellm2ut3a4edf9wh
Tags: 1.0~rc1~svn1492-1
* New upstream snapshot, past 1.0~rc1, as requested by Yaroslav
  Halchenko (Closes: #549996).
* Refresh patch accordingly:
   + debian/patches/10_doc_relocation.
* Get rid of extra LICENSE.txt file in /usr/share/doc.
* Use dh_compress -Xexamples/ to avoid compressing examples, thanks to
  Sandro Tosi (Closes: #539942).
* Bump Standards-Version from 3.8.0 to 3.8.3 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
nx_pydot
2
 
========
3
 
 
4
 
>>> from networkx import *
5
 
>>> from networkx.drawing import *
6
 
>>> from networkx.drawing.nx_agraph import *
7
 
 
8
 
>>> import os,sys
9
 
 
10
 
Undirected
11
 
----------
12
 
 
13
 
>>> H=Graph()
14
 
>>> H.add_edge('A','B')
15
 
>>> H.add_edge('A','C')
16
 
>>> H.add_edge('B','C')
17
 
>>> H.add_edge('A','D')
18
 
>>> H.add_node('E')
19
 
 
20
 
 
21
 
>>> A=to_agraph(H)
22
 
>>> N=Graph(from_agraph(A)) 
23
 
>>> sorted(N.nodes())==sorted(H.nodes())
24
 
True
25
 
>>> sorted(N.edges())==sorted(H.edges())
26
 
True
27
 
 
28
 
read write
29
 
----------
30
 
 
31
 
with file name
32
 
----------------
33
 
 
34
 
>>> import tempfile
35
 
>>> fname=tempfile.mktemp()
36
 
>>> write_dot(N,fname)
37
 
>>> Hin=Graph(read_dot(fname))
38
 
>>> os.unlink(fname)
39
 
>>> sorted(Hin.nodes())==sorted(H.nodes())
40
 
True
41
 
>>> sorted(Hin.edges())==sorted(H.edges())
42
 
True
43
 
 
44
 
with file handle
45
 
----------------
46
 
 
47
 
>>> (fd,fname)=tempfile.mkstemp()
48
 
>>> fh=open(fname,'w')
49
 
>>> write_dot(N,fh)
50
 
>>> fh.close()
51
 
 
52
 
 
53
 
>>> fh=open(fname,'r')
54
 
>>> Hin=Graph(read_dot(fh))
55
 
>>> sorted(Hin.nodes())==sorted(H.nodes())
56
 
True
57
 
>>> sorted(Hin.edges())==sorted(H.edges())
58
 
True
59
 
>>> fh.close()
60
 
>>> os.unlink(fname)
61
 
 
62
 
 
63
 
 
64
 
Directed
65
 
----------
66
 
 
67
 
>>> H=DiGraph()
68
 
>>> H.add_edge('A','B')
69
 
>>> H.add_edge('A','C')
70
 
>>> H.add_edge('B','C')
71
 
>>> H.add_edge('A','D')
72
 
>>> H.add_node('E')
73
 
 
74
 
 
75
 
>>> A=to_agraph(H)
76
 
>>> N=DiGraph(from_agraph(A))
77
 
>>> sorted(N.nodes())==sorted(H.nodes())
78
 
True
79
 
>>> sorted(N.edges())==sorted(H.edges())
80
 
True
81
 
 
82
 
>>> import tempfile
83
 
>>> fname=tempfile.mktemp()
84
 
>>> write_dot(N,fname)
85
 
 
86
 
 
87
 
>>> Hin=DiGraph(read_dot(fname))
88
 
>>> os.unlink(fname)
89
 
>>> sorted(Hin.nodes())==sorted(H.nodes())
90
 
True
91
 
>>> sorted(Hin.edges())==sorted(H.edges())
92
 
True
93
 
 
94
 
Layout
95
 
------
96
 
 
97
 
>>> pos=graphviz_layout(H,prog="circo",args="-Gepsilon=0.1")
98
 
 
99
 
 
100