GraphMatcher.subgraph_is_isomorphic#

GraphMatcher.subgraph_is_isomorphic()[source]#

Returns True if a subgraph of G1 is isomorphic to G2.

Examples

When creating the GraphMatcher, the order of the arguments is important

>>> G = nx.Graph([("A", "B"), ("B", "C"), ("A", "C")])
>>> H = nx.Graph([(0, 1), (1, 2), (0, 2), (1, 3), (0, 4)])

Check whether a subgraph of G is isomorphic to H:

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

Check whether a subgraph of H is isomorphic to G:

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