Expand description
Template matching — the arbitrary-graph arm.
This arm matches an arbitrary petgraph query graph against a host graph, in two
honestly-distinct semantics, and unlike the census/catalog arm
it is not bounded to k ≤ 5, honours node/edge weight predicates, and preserves
directedness.
- Induced (
induced_matches): delegated to petgraph’s VF2subgraph_isomorphisms_iter, which is node-induced native (its docstring states “‘subgraph’ always means a ‘node-induced subgraph’”, itsis_feasiblerejects extra host edges, and empirically a P3 pattern finds 0 matches in a triangle host). So the induced arm is free — we delegate and do no filtering. - Non-induced / monomorphism (
monomorphisms): a real ordered-backtracking subgraph-monomorphism enumerator (this crate’s own code — petgraph provides no monomorphism search, and it cannot be recovered by filtering the induced output since induced ⊂ monomorphism, a post-filter only shrinks). It returns every injective, edge-preserving (not edge-reflecting) mapping: every pattern edge maps to a host edge in the matching direction, but extra host edges among the image are allowed. Directed and undirected, with node/edge match predicates.
ADR-0290 originally deferred this monomorphism arm for want of a grounding consumer;
this module activates it as the arbitrary-template engine (the bounded-k catalog
arm still serves small named patterns via the verified s(P,C) census derivation).
§Counting semantics: raw embeddings, not distinct node-sets
Both arms return raw embeddings: each result is one ordered injection of pattern
nodes into host nodes, and pattern automorphisms are not deduped. A symmetric
pattern matched onto one image yields |Aut(pattern)| separate embeddings. For a
distinct-occurrence count, divide the raw count by |Aut(pattern)| (the catalog arm
and crate::catalog::find_motif do this dedup for the bounded-k patterns).
Functions§
- count_
induced_ matches - Count node-induced matches of
patterninhoston structure alone. - count_
monomorphisms - Count monomorphisms of
patterninhost, streaming (embeddings are counted, never materialized). Seemonomorphismsfor the raw-embedding semantics. - count_
monomorphisms_ unlabelled - Count monomorphisms of
patterninhoston structure alone. Seecount_monomorphisms. - induced_
matches - All node-induced matches of
patterninhost, each a vector indexed by pattern node with the matched host node index. Induced-native via petgraph VF2 (no filtering). - induced_
matches_ unlabelled - All node-induced matches of
patterninhoston structure alone (no node/edge predicates). Seeinduced_matches. - monomorphisms
- All monomorphisms (non-induced subgraph matches) of
patterninhost, each a vector indexed by pattern node with the matched host node index. - monomorphisms_
unlabelled - All monomorphisms of
patterninhoston structure alone (no predicates). Seemonomorphisms.