DiGraphMatcher.subgraph_is_isomorphic#
- DiGraphMatcher.subgraph_is_isomorphic()[source]#
Returns
True
if a subgraph ofG1
is isomorphic toG2
.Examples
When creating the
DiGraphMatcher
, the order of the arguments is important>>> G = nx.DiGraph([("A", "B"), ("B", "A"), ("B", "C"), ("C", "B")]) >>> H = nx.DiGraph(nx.path_graph(5))
Check whether a subgraph of G is isomorphic to H:
>>> isomatcher = nx.isomorphism.DiGraphMatcher(G, H) >>> isomatcher.subgraph_is_isomorphic() False
Check whether a subgraph of H is isomorphic to G:
>>> isomatcher = nx.isomorphism.DiGraphMatcher(H, G) >>> isomatcher.subgraph_is_isomorphic() True