from networkx import *
import pylab
def import_edge_list(path):
"""Returns a Graph created from an edge list stored in the file "path" """
G = Graph()
f = open(path)
for edge in f: # each line corresponds to an edge
src,dst = edge.split()
G.add_edge(src,dst) # add edge to graph
f.close()
return G
def count_degree(G,d):
"""Returns the number of nodes in graph G having degree at least d """
count_d = 0
# put your code here
return count_d
if __name__ == "__main__":
fname = raw_input("Enter file name (without quotes): ")
G = import_edge_list(fname)
degree = count_degree(G,5)
print "graph G has ", degree, "nodes have degree at least", 5
degree = count_degree(G,3)
print "graph G has ", degree, "nodes have degree at least", 3
# make a histogram of the node degrees
# Put your code here
# show the graph
pylab.figure(2)
draw(G) #draw_circular(G) may be helpful for some graphs
pylab.show()