答案 0 :(得分:0)
您需要使用NetworkX中可用的Graph Isomorphism。您可以检出here。
这是is_isomorphic
文档中的一个官方示例。您可以here查看它。
import networkx.algorithms.isomorphism as iso
import netoworkx as nx
G1 = nx.DiGraph()
G2 = nx.DiGraph()
nx.add_path(G1, [1,2,3,4], weight=1)
nx.add_path(G2, [10,20,30,40], weight=2)
# This will be used for attribute matching
em = iso.numerical_edge_match('weight', 1)
print(nx.is_isomorphic(G1, G2)) # no weights considered
#Output: True
print(nx.is_isomorphic(G1, G2, edge_match=em)) # match weights
# Output : False