<｜begin▁of▁sentence｜>### Instruction:
Given a bipartite graph with edge set [('a', 1), ('b', 1), ('a', 2), ('b', 2)], how do you project this graph onto the nodes ['a', 'b'] creating a multigraph that has an edge for every shared neighbor in the input graph?
### Response:
from networkx.algorithms import bipartite
B = nx.Graph()
B.add_edges_from([('a', 1), ('b', 1), ('a', 2), ('b', 2)])
G = bipartite.projected_graph(B, ['a', 'b'], multigraph=True)
print([sorted((u, v)) for u, v in G.edges()])
<|EOT|>
