DiGraphMatcher.subgraph_isomorphisms_iter#
- DiGraphMatcher.subgraph_isomorphisms_iter()[source]#
Generator over isomorphisms between a subgraph of
G1
andG2
.Examples
When creating the
DiGraphMatcher
, the order of the arguments is important>>> G = nx.DiGraph([("B", "C"), ("C", "B"), ("C", "D"), ("D", "C")]) >>> H = nx.DiGraph(nx.path_graph(5))
Yield isomorphic mappings between
H
and subgraphs ofG
:>>> isomatcher = nx.isomorphism.DiGraphMatcher(G, H) >>> list(isomatcher.subgraph_isomorphisms_iter()) []
Yield isomorphic mappings between
G
and subgraphs ofH
:>>> isomatcher = nx.isomorphism.DiGraphMatcher(H, G) >>> next(isomatcher.subgraph_isomorphisms_iter()) {0: 'B', 1: 'C', 2: 'D'}