title: Example 1$$ \begin{aligned} \text{degree}(a) &= 2 \\ \text{degree}(b) &= \text{degree}(c) = \text{degree}(f) = 4 \\ \text{degree}(e) &= 3 \\ \text{degree}(d) &= 1, \text{so } d \text{ is pendant} \\ \text{degree}(g) &= 0, \text{so } g \text{ is isolated} \\ \end{aligned}$$```graphvizgraph A { f,e--b,c f--e b--c a--b,f d--c g}
Basic terminology: directed graphs
If there is an edge e going from vertex u to v, we say that:
u is adjacent to v
u is the initial or start vertex of e
v is the terminal or end vertex of e
The in-degree of a vertex v is the number of edges with v as their terminal vertex.
The out-degree of a vertex v is the number of edges with v as their initial vertex.
Note: A loop at a vertex contributes to both the in and out degrees.
number of edges=sum of the in-degrees of vertices=sum of the out-degrees of vertices
title: Example 1$$(a,b,c,f,b,e) \text{ is a simple path in } G \text{ of length } 5$$```graphvizgraph G { a--d a--e d--c d--e e--f edge [colorscheme=orrd9] a--b [color=9 penwidth=3] b--c [color=8 penwidth=3] c--f [color=7 penwidth=3] f--b [color=6 penwidth=3] b--e [color=5 penwidth=3]}
title: Example 2$$(a,b,c,d,a,b) \text{ is a path in } G \text{ of length } 5 \text{ but it is not simple as it contains } a-b \text{ twice}$$```graphvizgraph G { a--e d--c e--f b--c c--f f--b edge [colorscheme=greens9] a--b [color=9 penwidth=5] b--e [color=8 penwidth=3] d--e [color=7 penwidth=3] a--d [color=6 penwidth=3]}
title: Example 3$$(d,a,e,b,f,c) \text{ is a Hamiltonian path in } G$$```graphvizgraph G { d--c e--f b--c a--b d--e edge [colorscheme=blues9] a--d [color=9 penwidth=3] a--e [color=8 penwidth=3] b--e [color=7 penwidth=3] f--b [color=6 penwidth=3] c--f [color=5 penwidth=3]}
title: Example 1$$(a,d,c,b,a) \text{ is a simple cycle in } G \text{ of length } 4$$```graphvizgraph G { a--e b--e b--f c--f d--e e--f a--d [penwidth=3] c--d [penwidth=3] b--c [penwidth=3] b--a [penwidth=3]}
title: Example 1$$(b,e,d,a,e,b) \text{ is a cycle in } G \text{ of length } 5 \text{ but it is not simple}$$```graphvizgraph G { a--e [penwidth=3] b--e [penwidth=6] b--f c--f d--e [penwidth=3] e--f a--d [penwidth=3] c--d b--c b--a}
title: Example 1$$(c,f,e,d,a,b,c) \text{ is a Hamiltonian cycle in } G$$```graphvizgraph G { a--e b--e b--f c--f [penwidth=3] d--e [penwidth=3] e--f [penwidth=3] a--d [penwidth=3] c--d b--c [penwidth=3] b--a [penwidth=3]}
A connected component of a graph is a maximal connected subgraph.
If a graph is connected, then it has only 1 connected component, itself.
But if it is not connected, then it can have more:
graph 1 { layout=circo node [shape=point] a [xlabel="a"] b [xlabel="b"] c [xlabel="c"] label="G₁" a--b,c b--c}graph 2 { layout=circo node [shape=point] d [xlabel="d"] e [xlabel="e"] label="G₂" d--e}graph 3 { layout=circo node [shape=point] g [xlabel="g"] h [xlabel="h"] f [xlabel="f"] label="G₃" g--h,f}
are the three connected components of:
graph G { node [shape=point] subgraph cluster_H { a [xlabel="a"] b [xlabel="b"] c [xlabel="c"] d [xlabel="d"] e [xlabel="e"] f [xlabel="f"] g [xlabel="g"] h [xlabel="h"] label="G₁" a--b,c b--c d--e g--h,f }}
title: ExampleThe function $f$ defined by taking$$ f(a) = A, f(b) = B, f(c) = C, f(d) = D, f(e) = E$$is an isomorphism, showing that graphs $G$ and $H$ are isomorphic.
Isomorphic or not?
We need to determine whether two graphs, say G and H are isomorphic or not.
isomorphicnot isomorphic=there is an isomorphism=there is no isomorphism
We can try all possible functions from G to H, and check whether any of them is an isomorphism.
But this might take a lot of time: there are 45=1024 possible functions even for this example.
Invariants
Invariant
A property P of graphs is called an invariant if ==it is ‘preserved under isomorphisms’:
If G and H are isomorphic graphs, and G has property P, then H has property P as well==.
title: Example 1: "Having $5$ vertices" is an invariantIf $G$ and $H$ are isomorphic graphs, and $G$ has $5$ vertices, then $H$ has $5$ vertices too.This is because, if $G$ and $H$ are isomorphic, then there is an isomorphism $f$ between them.- $f$ is a [[Bijection (function)|bijection (function)]] from the vertices of $G$ (domain) to the vertices of $H$ (codomain). ![[Bijection f between graphs]]- As $f$ is one-to-one, $H$ has at least $5$ vertices.- As $f$ is onto, $H$ has at most $5$ vertices.
title: Example 2: Determine whether $G$ and $H$ are isomorphic or notWe've just seen that the property "having $5$ vertices" is an invariant.This property holds for $G$, but not for $H$. Therefore, $G$ and $H$ are not isomorphic.```graphvizgraph G { label=G e--d,a d--a,c b--a,c}graph H { label=H w--z,x y--x,z}
title: Example 3: Determine whether $G$ and $G'$ are isomorphic or notIn this case, we say "having a vertex of degree $3$" is an **invariant**.This property holds in $G$ (e.g. $\text{degree}(a) = 3$), but does not hold in $G'$, showing that $G$ and $G'$ are not isomorphic.```graphvizgraph G { label=G b--a,c d--a,c,e,f c--e a--e c--f}graph H { label="G'" g--h,i,k,j k--i,j,l j--l,i i--h}
title: Example 4: Determine whether $G$ and $G'$ are isomorphic or notThe function $f$ defined by taking$$ f(a) = 4, f(b) = 2, f(c) = 3, f(d) = 1, f(e) = 5$$is an isomorphism (because $f$ is a bijection, takes edges to edges and non-edges to non-edges). This shows that graphs $G$ and $H$ are isomorphic.```graphvizgraph G { label=G d--e,a,b e--c,a a--c,b}graph H { label="H" 1--2,4,5 2--4 3--4,5 4--5}
title: Always keep in mind that if $h$ is an isomorphism between graphs $G$ and $H$, then for every vertex $x$ in $G$, the degrees of $x$ and $h(x)$ must be the same.
How to decide?
You are given a task to determine whether two graphs G and H are isomorphic or not.
It is not known:
whether the problem is solvable in polynomial time
we don’t know whether there is a method to check isomorphism without trying all functions
whether the problem is definitely NOT solvable in polynomial time
for many other problems, there are known proofs
We can try to determine in parallel whether:
We can describe a bijection between the vertices of G and HG that ‘takes’ edges to edges, non-edges to non-edges.
If we succeed, answer is yes.
We can find an invariantP and show that G has P but H doesn’t, or the other way around.
If we succeed, answer is no.