summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoraric <none@none>2010-08-07 00:15:03 +0000
committeraric <none@none>2010-08-07 00:15:03 +0000
commit71b903ceefdaff09d98d9659b1970a84b70f8227 (patch)
tree222c953d19eabfbe04edf64bb25d6dad10123cdb /examples
parent3dbcb7d523764d4cc9a1c6711dac7362f1630c59 (diff)
downloadnetworkx-71b903ceefdaff09d98d9659b1970a84b70f8227.tar.gz
Update for Python3. Refs #384
--HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401854
Diffstat (limited to 'examples')
-rw-r--r--examples/subclass/printgraph.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/subclass/printgraph.py b/examples/subclass/printgraph.py
index 64d1ae61..976ddf4c 100644
--- a/examples/subclass/printgraph.py
+++ b/examples/subclass/printgraph.py
@@ -96,14 +96,14 @@ class PrintGraph(Graph):
seen=set()
for u,nbrs in self.adjacency_iter():
if u in bunch:
- for v,datadict in nbrs.iteritems():
+ for v,datadict in nbrs.items():
if v in bunch and v not in seen:
dd=deepcopy(datadict)
H.add_edge(u,v,dd)
seen.add(u)
# copy node and graph attr dicts
H.node=dict( (n,deepcopy(d))
- for (n,d) in self.node.iteritems() if n in H)
+ for (n,d) in self.node.items() if n in H)
H.graph=deepcopy(self.graph)
return H
@@ -115,21 +115,21 @@ if __name__=='__main__':
G.add_nodes_from('bar',weight=8)
G.remove_node('b')
G.remove_nodes_from('ar')
- print G.nodes(data=True)
+ print(G.nodes(data=True))
G.add_edge(0,1,weight=10)
- print G.edges(data=True)
+ print(G.edges(data=True))
G.remove_edge(0,1)
- G.add_edges_from(zip(range(03),range(1,4)),weight=10)
- print G.edges(data=True)
- G.remove_edges_from(zip(range(03),range(1,4)))
- print G.edges(data=True)
+ G.add_edges_from(list(zip(list(range(0o3)),list(range(1,4)))),weight=10)
+ print(G.edges(data=True))
+ G.remove_edges_from(list(zip(list(range(0o3)),list(range(1,4)))))
+ print(G.edges(data=True))
G=PrintGraph()
- G.add_path(range(10))
- print "subgraph"
- H1=G.subgraph(range(4),copy=False)
- H2=G.subgraph(range(4),copy=False)
- print H1.edges()
- print H2.edges()
+ G.add_path(list(range(10)))
+ print("subgraph")
+ H1=G.subgraph(list(range(4)),copy=False)
+ H2=G.subgraph(list(range(4)),copy=False)
+ print(H1.edges())
+ print(H2.edges())