Skip to main content

Module template

Module template 

Source
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 VF2 subgraph_isomorphisms_iter, which is node-induced native (its docstring states “‘subgraph’ always means a ‘node-induced subgraph’”, its is_feasible rejects 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 pattern in host on structure alone.
count_monomorphisms
Count monomorphisms of pattern in host, streaming (embeddings are counted, never materialized). See monomorphisms for the raw-embedding semantics.
count_monomorphisms_unlabelled
Count monomorphisms of pattern in host on structure alone. See count_monomorphisms.
induced_matches
All node-induced matches of pattern in host, 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 pattern in host on structure alone (no node/edge predicates). See induced_matches.
monomorphisms
All monomorphisms (non-induced subgraph matches) of pattern in host, each a vector indexed by pattern node with the matched host node index.
monomorphisms_unlabelled
All monomorphisms of pattern in host on structure alone (no predicates). See monomorphisms.