DiGraphMatcher.subgraph_is_isomorphic#

DiGraphMatcher.subgraph_is_isomorphic()[source]#

如果 G1 的子图与 G2 同构,则返回 True

示例

创建 DiGraphMatcher 时,参数的顺序很重要

>>> G = nx.DiGraph([("A", "B"), ("B", "A"), ("B", "C"), ("C", "B")])
>>> H = nx.DiGraph(nx.path_graph(5))

检查 G 的子图是否与 H 同构

>>> isomatcher = nx.isomorphism.DiGraphMatcher(G, H)
>>> isomatcher.subgraph_is_isomorphic()
False

检查 H 的子图是否与 G 同构

>>> isomatcher = nx.isomorphism.DiGraphMatcher(H, G)
>>> isomatcher.subgraph_is_isomorphic()
True