Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #! /home/bekzhan/anaconda3/bin/python3
  2. import networkx as nx
  3. from networkx.algorithms import bipartite
  4. from matplotlib.pyplot import *
  5.  
  6. f = open("data.txt", "r")
  7. leftnodes = set()
  8. rightnodes = set()
  9. edges = []
  10. for line in f.readlines():
  11. l,r = line.split()
  12. leftnodes.add(l)
  13. rightnodes.add(r)
  14. edges.append((l,r))
  15. print(leftnodes)
  16. print(rightnodes)
  17. print(edges)
  18. B = nx.Graph()
  19. B.add_nodes_from(leftnodes, bipartite = 0)
  20. B.add_nodes_from(rightnodes, bipartite = 1)
  21. B.add_edges_from(edges)
  22. nx.draw(B)
  23. show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement