How this calculation works
Count adjacency-preserving maps from one simple undirected graph to another and return a witness when one exists. A graph homomorphism can map several source vertices to the same target vertex when adjacency constraints allow it. The exact integer count includes all labeled maps, so this is neither an isomorphism count nor a count of unlabeled copies.
hom(G,H)=number of maps f:V(G)→V(H) with uv∈E(G)⇒f(u)f(v)∈E(H).A worked example
A triangle maps into a loopless triangle only by assigning all three source vertices to different target vertices. There are 3!=6 maps. In contrast, nonadjacent vertices of another source graph may share a target image, so homomorphisms need not be injective.
Good to know
Source≤8, target≤6 vertices, simple loopless undirected input. Exact integer count after at most 2,000,000 search states. A cap error is not a partial count. No counting modulo target symmetries or induced-map condition.
Reference: Method reference: Graph homomorphism count calculator for two graphs (opens in a new tab) ↗
What a homomorphism preserves
Every source edge must map to an edge of the target. Nonedges impose no restriction, and distinct source vertices need not have distinct images.
Because the target here has no loops, endpoints of a source edge cannot map to the same target vertex. Nonadjacent vertices can share an image freely if their other edge constraints are satisfied. This asymmetry is the central distinction from graph isomorphism, which is a bijection preserving both edges and nonedges.
Maps may identify vertices and need not be bijective; isomorphism testing cannot supply the full homomorphism count. The List coloring calculator with allowed colors at each vertex offers a complementary calculation under its own stated assumptions.
Counting labeled assignments
The target labels distinguish possible images, and the source labels distinguish variables being assigned. Automorphisms can therefore produce several counted maps that look visually similar.
An edgeless source with n vertices has m raised to n homomorphisms into an m-vertex target because there are no edge restrictions. Dividing by an automorphism count does not generally turn this output into a subgraph count; repeated images and different stabilizers make that shortcut invalid.
Worked example and mathematical rule
A triangle maps into a loopless triangle only by assigning all three source vertices to different target vertices. There are 3!=6 maps. In contrast, nonadjacent vertices of another source graph may share a target image, so homomorphisms need not be injective.
hom(G,H)=number of maps f:V(G)→V(H) with uv∈E(G)⇒f(u)f(v)∈E(H).
Coloring as a special case
Mapping a graph to the complete graph on k target vertices is exactly a proper coloring with k labeled colors. Adjacent source vertices must receive different images, while every pair of different target labels is adjacent.
The number includes color permutations. General target graphs impose additional restrictions between color-like labels, so their homomorphisms represent more than ordinary coloring. This connection is useful for interpreting zero counts and for independently checking small complete-target examples.
How the search prunes assignments
The implementation chooses source vertices and tests each proposed image against already assigned neighbors. It counts every surviving complete assignment using exact integers and retains one witness.
A bounded search cap prevents explosive instances from monopolizing the page. Exceeding that cap is an incomplete search error, not a zero count. The final witness alone certifies existence, whereas a total count requires completing all relevant assignments.
Disconnected components and isolated vertices
Assignments on disconnected source components are independent when the target is fixed, so component homomorphism counts multiply. An isolated source vertex contributes a factor equal to the number of target vertices.
A disconnected target can still receive a connected source graph, but all images of a nontrivial connected source component must stay within one target component. These facts offer useful small-instance checks without enumerating every map by hand.
Using the output without overclaiming
Verify a witness by replacing each source edge’s endpoints with their images and checking the resulting target pair. Do not demand preservation of missing edges or injectivity unless you actually need a stronger mapping notion.
A positive count into a target can establish a coloring-like structural property, but it does not imply the source occurs as a literal subgraph. Retain input vertex orders and search status when comparing counts across software, since an unnoticed relabeling of the target size changes the counting space.
A few questions, answered
Can two vertices map to one target vertex?
Yes, provided every source edge still maps to a target edge.
Are these subgraph embeddings?
No. Homomorphisms need not be injective.
What does a complete target represent?
A complete k-vertex target makes homomorphisms equivalent to proper colorings with k labeled colors.
Are color permutations counted separately?
Yes. Target labels distinguish the assignments.