summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorysitu <ysitu@users.noreply.github.com>2014-06-25 19:27:08 -0400
committerysitu <ysitu@users.noreply.github.com>2014-07-15 15:29:28 -0400
commita3bc59fcb27e1fc0590454cbb0abf0cb38e8984d (patch)
tree100768574d13311f542ea4aaaa273197104b2813
parentcf6ce260f7b2025fc048d076b88e98bb4ca2beee (diff)
downloadnetworkx-a3bc59fcb27e1fc0590454cbb0abf0cb38e8984d.tar.gz
Adapt print statements in examples for Python 3 compatibility
-rw-r--r--examples/algorithms/rcm.py6
-rw-r--r--examples/drawing/giant_component.py2
-rw-r--r--examples/drawing/lanl_routes.py8
-rw-r--r--examples/pygraphviz/write_dotfile.py12
4 files changed, 14 insertions, 14 deletions
diff --git a/examples/algorithms/rcm.py b/examples/algorithms/rcm.py
index 51c2c6c1..54418a21 100644
--- a/examples/algorithms/rcm.py
+++ b/examples/algorithms/rcm.py
@@ -12,7 +12,7 @@ import numpy as np
# build low-bandwidth numpy matrix
G=nx.grid_2d_graph(3,3)
rcm = list(reverse_cuthill_mckee_ordering(G))
-print "ordering",rcm
+print("ordering",rcm)
print("unordered Laplacian matrix")
A = nx.laplacian_matrix(G)
@@ -20,7 +20,7 @@ x,y = np.nonzero(A)
#print("lower bandwidth:",(y-x).max())
#print("upper bandwidth:",(x-y).max())
print("bandwidth: %d"%((y-x).max()+(x-y).max()+1))
-print A
+print(A)
B = nx.laplacian_matrix(G,nodelist=rcm)
print("low-bandwidth Laplacian matrix")
@@ -28,5 +28,5 @@ x,y = np.nonzero(B)
#print("lower bandwidth:",(y-x).max())
#print("upper bandwidth:",(x-y).max())
print("bandwidth: %d"%((y-x).max()+(x-y).max()+1))
-print B
+print(B)
diff --git a/examples/drawing/giant_component.py b/examples/drawing/giant_component.py
index 3208342b..c087a133 100644
--- a/examples/drawing/giant_component.py
+++ b/examples/drawing/giant_component.py
@@ -25,7 +25,7 @@ try:
from networkx import graphviz_layout
layout=nx.graphviz_layout
except ImportError:
- print "PyGraphviz not found; drawing with spring layout; will be slow."
+ print("PyGraphviz not found; drawing with spring layout; will be slow.")
layout=nx.spring_layout
diff --git a/examples/drawing/lanl_routes.py b/examples/drawing/lanl_routes.py
index ec07491a..11903fa6 100644
--- a/examples/drawing/lanl_routes.py
+++ b/examples/drawing/lanl_routes.py
@@ -21,7 +21,7 @@ def lanl_graph():
try:
fh=open('lanl_routes.edgelist','r')
except IOError:
- print "lanl.edges not found"
+ print("lanl.edges not found")
raise
G=nx.Graph()
@@ -52,9 +52,9 @@ if __name__ == '__main__':
G=lanl_graph()
- print "graph has %d nodes with %d edges"\
- %(nx.number_of_nodes(G),nx.number_of_edges(G))
- print nx.number_connected_components(G),"connected components"
+ print("graph has %d nodes with %d edges"\
+ %(nx.number_of_nodes(G),nx.number_of_edges(G)))
+ print(nx.number_connected_components(G),"connected components")
import matplotlib.pyplot as plt
plt.figure(figsize=(8,8))
diff --git a/examples/pygraphviz/write_dotfile.py b/examples/pygraphviz/write_dotfile.py
index 071808bf..5e5b490a 100644
--- a/examples/pygraphviz/write_dotfile.py
+++ b/examples/pygraphviz/write_dotfile.py
@@ -23,15 +23,15 @@ import networkx as NX
try:
m=NX.drawing.write_dot.__module__
except:
- print
- print "pygraphviz or pydot were not found "
- print "see https://networkx.lanl.gov/Drawing.html for info"
- print
+ print()
+ print("pygraphviz or pydot were not found ")
+ print("see https://networkx.lanl.gov/Drawing.html for info")
+ print()
raise
-print "using module", m
+print("using module", m)
G=NX.grid_2d_graph(5,5) # 5x5 grid
NX.write_dot(G,"grid.dot")
-print "Now run: neato -Tps grid.dot >grid.ps"
+print("Now run: neato -Tps grid.dot >grid.ps")