Skip to content

feat(math): add graph morphism operations (#1856) - #2043

Open
morluto wants to merge 1 commit into
mainfrom
agent/graph-morphisms-1856
Open

feat(math): add graph morphism operations (#1856)#2043
morluto wants to merge 1 commit into
mainfrom
agent/graph-morphisms-1856

Conversation

@morluto

@morluto morluto commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

Implements graph morphism operations for homomorphism checking, search, core detection, and retraction.

Closes #1856

Operations

Operation Description
graph.homomorphism.check Check if a vertex map is a graph homomorphism
graph.homomorphism.find Find a homomorphism via backtracking search
graph.core.check Check if a graph is a core (no non-injective endomorphism)
graph.retraction.check Check if a retraction onto an induced subgraph exists

Design

  • Exact adjacency checking: All homomorphism checks use exact edge-preserving verification over adjacency sets.
  • Backtracking search: Homomorphism finding uses systematic backtracking over all possible vertex maps, bounded by the vertex count limit (≤64).
  • Core detection: A graph is a core iff it has no non-injective endomorphism; the operation searches for one.
  • Retraction: Checks for a homomorphism from G to an induced subgraph H that fixes every vertex of H.

Continue this on Linzumi

Add graph.homomorphism.check, graph.homomorphism.find,
graph.core.check, and graph.retraction.check operations for graph
morphism theory. Uses exact edge-preserving checks and backtracking
search over bounded simple undirected graphs.

Closes #1856
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

morluto commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Deep review summary

Verdict: REQUEST CHANGES — the core checker prunes every partial assignment incorrectly and reports many non-core graphs as cores; all search operations are also effectively unbounded.

1. graph.core.check is wrong for any ordinary graph with edges

During backtracking, _is_endomorphism() checks all source edges even though most vertices are still mapped to -1. At the first partial assignment, an edge touching an unassigned vertex becomes (mapped, -1) or (-1, -1), is absent from the adjacency set, and the branch is rejected before the remaining vertices can be assigned.

Thus the search generally never reaches a complete mapping and reports is_core=True. A path on three vertices is a concrete counterexample: it has the non-injective endomorphism mapping both endpoints to one endpoint and the middle vertex to the other, so it is not a core, but this implementation reports it as a core.

Use the same partial-edge discipline as the homomorphism finder: test an edge only after both endpoints are assigned, and replay the full homomorphism plus non-injectivity predicate at the leaf. Add regressions for P3 (not a core), K_n (core), bipartite graphs retracting to K2, and edgeless graphs.

2. The accepted search domain is not bounded

Homomorphism search can explore |V(H)|^|V(G)|, core search n^n, and retraction search |S|^(n-|S|), with public vertex bounds of 64 and no node budget, timeout status, or complexity-derived request restriction. Those are not total bounded operations.

Either impose small, justified work-product bounds and test worst cases, or expose max_nodes with explicit FOUND / NOT_FOUND_COMPLETE / INCOMPLETE outcomes. A timed-out search must not be reported as mathematical nonexistence.

The direct graph.homomorphism.check predicate is correct for the represented loopless simple graphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Graph morphisms] Add exact homomorphism, retraction, endomorphism, core, and bounded search operations

1 participant