Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > 08dc075002a4e7b275dd7256439fe79b > files > 345

python-networkx-1.2-1mdv2010.1.noarch.rpm

#!/usr/bin/env python
"""
Read and write graphs.
"""
__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
#    Copyright (C) 2004-2006 by 
#    Aric Hagberg <hagberg@lanl.gov>
#    Dan Schult <dschult@colgate.edu>
#    Pieter Swart <swart@lanl.gov>
#    All rights reserved.
#    BSD license.

from networkx import *
import sys
G=grid_2d_graph(5,5)  # 5x5 grid
write_adjlist(G,sys.stdout) # write adjacency list to screen
# write edgelist to grid.edgelist
write_edgelist(G,path="grid.edgelist",delimiter=":") 
# read edgelist from grid.edgelist
H=read_edgelist(path="grid.edgelist",delimiter=":")