我正在使用networkx从文件列表构建二分图:
for i, f in enumerate(glob.glob("*.json")):
with open( f , 'r') as content:
...
graph.add_nodes_from( _type_A , bipartite=0)
for _type_B in properties:
graph.add_nodes_from( _type_B , bipartite=1)
graph.add_edges_from( [(_type_A, _type_B )])
但它没有认出这两套。
x, y = nx.bipartite.sets(graph)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/networkx/algorithms/bipartite/basic.py", line 170, in sets
c = color(G)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/networkx/algorithms/bipartite/basic.py", line 78, in color
raise nx.NetworkXError("Graph is not bipartite.")
networkx.exception.NetworkXError: Graph is not bipartite.
你能帮忙理解为什么吗?