DiGraphMatcher.subgraph_monomorphisms_iter#

DiGraphMatcher.subgraph_monomorphisms_iter()[source]#

Generator over monomorphisms between a subgraph of G1 and G2.

Examples

When creating the DiGraphMatcher, the order of the arguments is important.

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

Yield monomorphic mappings between H and subgraphs of G:

>>> isomatcher = nx.isomorphism.DiGraphMatcher(G, H)
>>> list(isomatcher.subgraph_monomorphisms_iter())
[]

Yield monomorphic mappings between G and subgraphs of H:

>>> isomatcher = nx.isomorphism.DiGraphMatcher(H, G)
>>> next(isomatcher.subgraph_monomorphisms_iter())
{3: 'A', 2: 'B', 1: 'C', 0: 'D'}