~ubuntu-branches/ubuntu/wily/python-networkx/wily

« back to all changes in this revision

Viewing changes to networkx/tests/readwrite/nx_yaml.txt

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-03-02 01:06:32 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080302010632-1lp6qe1orf59jl8b
* debian/control:
   + Replace python-setuptools with python-pkg-resources in the
     “Recommends:” since pkg_resources is now available in this
     separate package, thanks Matthias Klose (Closes: #468721).
* debian/copyright:
   + Use “© $years $name” instead of invalid “$name, $years” and
     “(C) $years, $name”, thanks to lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
>>> from networkx import *
 
2
>>> from networkx.operators import *
 
3
>>> import os,tempfile
 
4
 
 
5
>>> G=Graph(name="test")
 
6
>>> e=[('a','b'),('b','c'),('c','d'),('d','e'),('e','f'),('a','f')]
 
7
>>> G.add_edges_from(e)
 
8
>>> G.add_node('g')
 
9
>>> DG=G.to_directed()
 
10
>>> XG=XGraph(multiedges=True,selfloops=True)
 
11
>>> XG.add_edges_from([(1,2,5),(1,2,5),(1,2),(3,3,42)])
 
12
 
 
13
 
 
14
YAML
 
15
----
 
16
 
 
17
>>> (fd,fname)=tempfile.mkstemp()
 
18
>>> write_yaml(G,fname);  
 
19
>>> Gin=read_yaml(fname);
 
20
>>> sorted(G.nodes())==sorted(Gin.nodes())
 
21
True
 
22
>>> sorted(G.edges())==sorted(Gin.edges())
 
23
True
 
24
>>> os.close(fd)
 
25
>>> os.unlink(fname)
 
26
 
 
27
 
 
28
>>> (fd,fname)=tempfile.mkstemp()
 
29
>>> write_yaml(DG,fname);  
 
30
>>> Gin=read_yaml(fname);
 
31
>>> sorted(DG.nodes())==sorted(Gin.nodes())
 
32
True
 
33
>>> sorted(DG.edges())==sorted(Gin.edges())
 
34
True
 
35
>>> os.close(fd)
 
36
>>> os.unlink(fname)
 
37
 
 
38
 
 
39
>>> (fd,fname)=tempfile.mkstemp()
 
40
>>> write_yaml(XG,fname);  
 
41
>>> Gin=read_yaml(fname);
 
42
>>> sorted(XG.nodes())==sorted(Gin.nodes())
 
43
True
 
44
>>> sorted(XG.edges())==sorted(Gin.edges())
 
45
True
 
46
>>> os.close(fd)
 
47
>>> os.unlink(fname)
 
48
 
 
49