GraphMatcher.subgraph_is_isomorphic#
- GraphMatcher.subgraph_is_isomorphic()[source]#
如果
G1
的子图与G2
同构,则返回True
。示例
创建
GraphMatcher
时,参数的顺序很重要>>> G = nx.Graph([("A", "B"), ("B", "C"), ("A", "C")]) >>> H = nx.Graph([(0, 1), (1, 2), (0, 2), (1, 3), (0, 4)])
检查 G 的子图是否与 H 同构
>>> isomatcher = nx.isomorphism.GraphMatcher(G, H) >>> isomatcher.subgraph_is_isomorphic() False
检查 H 的子图是否与 G 同构
>>> isomatcher = nx.isomorphism.GraphMatcher(H, G) >>> isomatcher.subgraph_is_isomorphic() True