~ubuntu-branches/ubuntu/raring/python-networkx/raring

« back to all changes in this revision

Viewing changes to networkx/readwrite/edgelist.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2011-03-19 12:19:16 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110319121916-xrhlpiwc9sa5e028
Tags: 1.4-1
* New upstream release; thanks to Yaroslav Halchenko for the report;
  Closes: #617677
* debian/rules
  - don't compress objects.inv; thanks to Michael Fladischer for the report;
    Closes: #608780
* debian/watch
  - updated to point to PyPi
* debian/control
  - bump python-sphinx versioned b-d-i to 1.0.1 minimum
  - added python-pygraphviz to b-d-i, needed for doc building
* debian/copyright
  - bump upstream and packaging copyright years
* debian/patches/{40_add_networkxcss, 50_boundary-test-fix.patch
                  60_remove_svn_refs.diff 70_set_matplotlib_ps_backend.patch}
  - removed since merged upstream
* debian/patches/{10_doc_relocation, 20_example_dirs_remove,
                  30_use_local_objects.inv}
  - refreshed/adapted to new upstream code

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 1 2 7 green
28
28
"""
29
29
__author__ = """Aric Hagberg (hagberg@lanl.gov)\nDan Schult (dschult@colgate.edu)"""
30
 
#    Copyright (C) 2004-2010 by 
 
30
#    Copyright (C) 2004-2011 by 
31
31
#    Aric Hagberg <hagberg@lanl.gov>
32
32
#    Dan Schult <dschult@colgate.edu>
33
33
#    Pieter Swart <swart@lanl.gov>
59
59
       representation of edge data.  If a list of keys use a list of data
60
60
       values corresponding to the keys.
61
61
 
62
 
    Yields
63
 
    ------
 
62
    Returns
 
63
    -------
64
64
    lines : string
65
65
        Lines of data in adjlist format.
66
66
 
337
337
    >>> G=nx.read_edgelist("test.edgelist", nodetype=int)
338
338
    >>> G=nx.read_edgelist("test.edgelist",create_using=nx.DiGraph())
339
339
 
 
340
    Edgelist with data in a list:
 
341
 
 
342
    >>> textline = '1 2 3'
 
343
    >>> open('test.edgelist','w').write(textline)
 
344
    >>> G = nx.read_edgelist('test.edgelist', nodetype=int, data=(('weight',float),))
 
345
    >>> G.nodes()
 
346
    [1, 2]
 
347
    >>> G.edges(data = True)
 
348
    [(1, 2, {'weight': 3.0})]
 
349
 
340
350
    See parse_edgelist() for more examples of formatting.
341
351
 
342
352
    See Also
378
388
    --------
379
389
    >>> G=nx.Graph()
380
390
    >>> G.add_edge(1,2,weight=7)
381
 
    >>> nx.write_weighted_edgelist(G, 'weighted.edgelist')
 
391
    >>> nx.write_weighted_edgelist(G, 'test.weighted.edgelist')
382
392
 
383
393
    See Also
384
394
    --------
442
452
                         data=(('weight',float),),
443
453
                         encoding = encoding
444
454
                         )
 
455
 
 
456
 
 
457
# fixture for nose tests
 
458
def teardown_module(module):
 
459
    import os
 
460
    os.unlink('test.edgelist')
 
461
    os.unlink('test.edgelist.gz')
 
462
    os.unlink('test.weighted.edgelist')