ISMAGS.monomorphisms_iter#
- ISMAGS.monomorphisms_iter(symmetry=True)[source]#
Yields all monomorphisms from
graphtosubgraphEach mapping assigns distinct nodes in
graphto all nodes insubgraph, preserving the connectivity and node/edge matches required bysubgraph. Extra edges between matched nodes ingraphare allowed, so the matched subgraph need not be induced. For multigraphs,graphmust supply at least the required number of parallel edges and self-loops, subject to the edge-matching function.Symmetric monomorphisms can be ignored for the symmetries of
subgraph.- Parameters:
- symmetrybool, optional (default: True)
Whether symmetries of
subgraphshould be taken into account. If False, monomorphisms may be symmetrically equivalent.
- Yields:
- dict
The monomorphism mappings in form:
{graph_node: subgraph_node}.
Examples
A triangle contains a path as a non-induced subgraph. Accounting for the path’s reflection symmetry halves the number of reported mappings.
>>> matcher = ISMAGS(nx.cycle_graph(3), nx.path_graph(3)) >>> matcher.subgraph_is_isomorphic() False >>> len(list(matcher.monomorphisms_iter(symmetry=False))) 6 >>> len(list(matcher.monomorphisms_iter())) 3