definition example theorem

A graph homomorphism between graphs consists of functions and such that

i.e. it “preserves sources and targets”: an edge goes to an edge . Exactly as a functor sends to . The two conditions are commutative squares — the naturality squares of a Natural Transformation between .

G(E)H(E)G(E)H(E)G(V)H(V)G(V)H(V)®EG(src)H(src)®EG(tgt)H(tgt)®V®VG(E)H(E)G(E)H(E)G(V)H(V)G(V)H(V)®EG(src)H(src)®EG(tgt)H(tgt)®V®V

Sources: Kittenlab Lecture 6 (“Sneak peak: natural transformations”), 7; 7 Sketches §3.3.5, Example 3.63, Exercise 3.64; CTfS Definition 3.3.3.1, Remark 3.3.3.2, Example 3.3.3.3, Exercises 3.3.3.5–3.3.3.6, 4.1.1.14–4.1.1.15, Example 4.3.1.12

Example 3.63/7S Exercise 3.64. , . The unique homomorphism with has , , .

Example (Kittenlab). A three-colouring of is a homomorphism into the triangle graph : adjacent vertices get different colours because has no loops. Catlab’s homomorphisms search solves such constraint problems.

“Arrows are bound to their vertices” (CTfS Remark 3.3.3.2): one cannot send an arrow to an arrow while sending . The two squares can equivalently be packaged as one square with and (CTfS Exercise 3.3.3.6). A homomorphism sends paths to paths of the same length; if are injective so is the induced map on paths, but surjectivity on vertices and arrows does not imply surjectivity on paths (CTfS Exercise 3.3.3.5). A homomorphism is an isomorphism iff both components are bijections (CTfS Exercises 4.1.1.14–4.1.1.15).

is the category of graphs and graph homomorphisms; its isomorphisms are relabelings; monos are subgraph inclusions.

Docs: Categories & functors · C-set morphisms · ACSets API · Graphs · Vignette: graphs — Kittenlab Lecture 6

using Catlab
G = @acset Graph begin V = 3; E = 2; src = [1, 2]; tgt = [2, 3] end
H = @acset Graph begin V = 2; E = 3; src = [1, 1, 2]; tgt = [2, 2, 2] end
α = ACSetTransformation(G, H; V = [1, 2, 2], E = [2, 3])
is_natural(α)                                    # true
# three-colourings of the 5-cycle
K3 = complete_graph(Graph, 3)                    # (with both edge directions)
length(homomorphisms(cycle_graph(Graph, 5), K3)) # 30
#check Prefunctor            -- V ⥤q W: obj and map, i.e. a graph homomorphism of quivers
#check SimpleGraph.Hom       -- homomorphisms of simple graphs
-- check the two naturality squares on finite graphs
isGraphHom :: (Eq v') => Graph v e -> Graph v' e' -> (v -> v') -> (e -> e') -> Bool
isGraphHom g h fv fe = and [ fv (src g e) == src h (fe e) && fv (tgt g e) == tgt h (fe e) | e <- edges g ]