alireza_sh1992

Untitled

Oct 16th, 2016
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import networkx as nx
  2. import pylab as plt
  3. from collections import Counter
  4.  
  5. webg = nx.read_edgelist('web-graph.txt',create_using=nx.DiGraph(),nodetype=int)
  6. in_degrees = webg.in_degree()
  7. in_values = sorted(set(in_degrees.values()))
  8. #in_hist = [in_degrees.values().count(x)for x in in_values]
  9. in_hist = Counter(in_degrees.values())
  10.  
  11. plt.figure()
  12. plt.grid(True)
  13. plt.plot(in_values,in_hist,'ro-')
  14. plt.plot(out_values,out_hist,'bv-')
  15. plt.legend(['in-degree','Out-degree'])
  16. plt.xlabel('Degree')
  17. plt.ylabel('Number of nodes')
  18. plt.title('web graph degree')
  19. plt.xlim([0,2*10**2])
  20. plt.savefig('/home/alireza/web-graph-degree.pdf')
  21. plt.close()
Add Comment
Please, Sign In to add comment