GraphMatcher.subgraph_monomorphisms_iter#
- GraphMatcher.subgraph_monomorphisms_iter()[source]#
Generator over monomorphisms between a subgraph of
G1
andG2
.Examples
When creating the
GraphMatcher
, the order of the arguments is important.>>> G = nx.Graph([("A", "B"), ("B", "C")]) >>> H = nx.Graph([(0, 1), (1, 2), (0, 2)])
Yield monomorphic mappings between
H
and subgraphs ofG
:>>> isomatcher = nx.isomorphism.GraphMatcher(G, H) >>> list(isomatcher.subgraph_monomorphisms_iter()) []
Yield monomorphic mappings between
G
and subgraphs ofH
:>>> isomatcher = nx.isomorphism.GraphMatcher(H, G) >>> next(isomatcher.subgraph_monomorphisms_iter()) {0: 'A', 1: 'B', 2: 'C'}