GraphMatcher.subgraph_isomorphisms_iter#

GraphMatcher.subgraph_isomorphisms_iter()[source]#

Generator over isomorphisms between a subgraph of G1 and 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)])

Yield isomorphic mappings between H and subgraphs of G:

>>> isomatcher = nx.isomorphism.GraphMatcher(G, H)
>>> list(isomatcher.subgraph_isomorphisms_iter())
[]

Yield isomorphic mappings between G and subgraphs of H:

>>> isomatcher = nx.isomorphism.GraphMatcher(H, G)
>>> next(isomatcher.subgraph_isomorphisms_iter())
{0: 'A', 1: 'B', 2: 'C'}