Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python3
- import networkx as nx
- from networkx.algorithms import bipartite
- f = open("data.txt", "r")
- leftnodes = set()
- rightnodes = set()
- edges = []
- for line in f.readlines():
- l,r = line.split()
- leftnodes.add(l)
- rightnodes.add(r)
- edges.append((l,r))
- print(leftnodes)
- print(rightnodes)
- print(edges)
- B = nx.Graph()
- B.add_nodes_from(leftnodes, bipartite = 0)
- B.add_nodes_from(rightnodes, bipartite = 1)
- B.add_edges_from(edges)
- nx.draw(B)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement