Advertisement
Guest User

Untitled

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