ISMAGS.monomorphisms_iter#

ISMAGS.monomorphisms_iter(symmetry=True)[source]#

Yields all monomorphisms from graph to subgraph

Each mapping assigns distinct nodes in graph to all nodes in subgraph, preserving the connectivity and node/edge matches required by subgraph. Extra edges between matched nodes in graph are allowed, so the matched subgraph need not be induced. For multigraphs, graph must 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 subgraph should 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