擅长:python、mysql、java
<p>既然你已经知道你的二部集是什么,你可以显式地指定它们。在</p>
<pre><code>import networkx as nx
from networkx.algorithms import bipartite
x=(161,1),(589,2),(162,1),(163,1),(589,2)
BI = nx.Graph(x)
top = set(s for s,t in x)
print(top)
GI = bipartite.projected_graph(BI, top)
print(list(GI.edges()))
</code></pre>
<p>输出</p>
^{pr2}$