4.1.8.6. dg/VertexMapper¶
- class mod.DGVertexMapper¶
A class for enumerating vertex maps for a given
DG.HyperEdge
.For the given hyperedge, collect the graphs associated with respectively the source and target vertices, and create the disjoint union of those graphs. Let the result be the graphs \(G\) and \(H\), available via DGVertexMapper.left and DGVertexMapper.right respectively. Then each rule \(p = (L\leftarrow K\rightarrow R)\) associated with the hyperedge, generate direct derivations \(\require{mathtools} G\xRightarrow{p, m} H'\). An isomorphism \(H'\rightarrow H\) is then found to ensure we have generated the correct product. Each result can be described in the following commutative diagram.
A diagram describing each result generated by the vertex mapper. A consists of a double-pushout diagram for a direct derivation \(G\xRightarrow{p, m} H'\) and an isomorphism \(H'\rightarrow H\).
Each result is available in the form of three vertex maps:
Result::map (\(V(G) \rightarrow V(H)\)): the vertex map of the derivation, which maps vertices of the input graph \(G\) to the product graph \(H\). The map is defined as the composition \(b\circ h\circ g^{-1}\). Note that if the rule \(p\) either creates or removes vertices, then the map is partial. As all morphisms are injective, the vertex map is as well.
Result::match (\(m\colon L\rightarrow G\)): the match morphism.
Result::comatch (\(m'\colon L\rightarrow H\)): the comatch morphism. It is defined as the composition \(b\circ a\).
The vertex mapper can be configured in two ways via the constructor:
upToIsomorphismGDH
: this controls which spans \(G\leftarrow D\rightarrow H'\) and match morphisms \(m\colon L\rightarrow G\) are enumerated. When set true only a single representative of the span is generated per isomorphism class.rightLimit
: this controls the amount of isomorphisms \(b\colon H'\rightarrow H\) are generated.
For example:
If you just want a single result, then use
upToIsomorphismGDH = True
andrightLimit = 1
.If you want all different vertex maps \(V(G)\rightarrow V(H)\), then use
upToIsomorphismGDH = True
andrightLimit
set to some arbitrary high value, e.g., \(2^{30}\).If you are interested in all the different ways the rule can be matched to generate this direct derivation, but do not care about the specific vertex map \(V(G)\rightarrow V(H)\), then use
upToIsomorphismGDH = False
andrightLimit = 1
.And finally, if you want all possible results, then use
upToIsomorphismGDH = False
and setrightLimit
to some high value, e.g., \(2^{30}\).
- __init__(e, upToIsomorphismGDH=True, rightLimit=2**30)¶
Construct a vertex map holder, and immediately calculate vertex maps for the derivations underlying the given hyperedge.
- Parameters:
e (DG.HyperEdge) – the hyperedge to construct vertex maps for.
upToIsomorphismGDH (bool) – whether to only enumerate spans \(G \leftarrow D\rightarrow H'\) up to isomorphism, all \(m\), or just those such that all bottom spans \((G\leftarrow D\rightarrow H)\) up to isomorphism are generated. Defaults to
True
.rightLimit (int) – after bottom span generation, find this many isomorphisms back to the targets of the hyperedge.
- Raises:
LogicError
ifnot e
.
- edge¶
(Read-only) The hyperedge to calculate vertex maps for.
- Type:
- left¶
- right¶
- Returns:
the disjoint union of graphs from respectively the source and target vertices of the hyperedge. That is, the graphs \(G\) and \(H\).
- Type:
- __iter__()¶
- Returns:
an iterator over the vertex maps, see
__getitem__()
for the specific type.
- __getitem__(i)¶
- Parameters:
i (int) – the index of the map to retrieve.
- Returns:
the
i
th vertex map.- Return type:
- Raises:
LogicError
ifi
is out of range.