# Lecture 009

Undirected Graph ($G = (V, E)$, where $V, E$ are sets): may not be all reachable

• $1 \leq n = |V|$: number of vertice

• $0 \leq m = |E| \leq n^2$: number of edges

• Trivial Graph: $n = 1$

• Regular Graph: every vertex has same degree ($d$-regular if all vertices has degree of $d$)

• Empty Graph: $0$-regular
• Perfect Matching: $1$-regular. Only possible when $|V|$ is even
• $2$-Regular Graph: form $c$-cycles where $c$ is the circumference of cycles
• Complete Graph ($K_n = (V, E)$): $m = n^2$ (Complete Graph is $n-1$-regular)
• Sparse Graph: $m = O(n)$

• Dense Graph: $m = \Omega(n^2)$

• Connected Graph: $(\forall u, v \in V)(v \text{is reachabble from }u)$

• connected component: a subgraph that is connected
• $n-1$ edges is enough to make a graph connected, in fact, you always need $n-1$ edges
• acyclic: iff $G$ has exactly $n-1$ edges
• tree: acyclic, connected, with $n-1$ edges (any 2 of these properties implies 3rd property)
• leaf: vertex of $\text{degree } = 1$
• internal vertice: vertex of $\text{degree } > 1$
• rooted tree: pick any vertex as the root of the tree
• parent, child, sibling, ancestor, descendant
• binary tree: a rooted tree with at most 2 children

Walk(path): walk in $G$ is sequence of vertices $v_0, v_1, v_2, ..., v_n$ such that $(\forall 1 \leq t \leq n)(\{v_{t-1}, v_t\} \in E)$

• walk length: length of walk from $v_0$ to $v_n$ is $n$.

• distance: length of shorted path $\text{dist}(u, v) = \min(|\pi| | \pi : u \rightarrow v)$

• simple: all vertices are distinct in path

• cycle: source is the target for $|V| \geq 1$

• simple cycle: all nodes appear once, ignore the target

Cost Function: $\lambda: E \rightarrow \mathbb{N}_+$

• Path Cost: $\lambda(\pi) = \sum_{p \in \pi} \lambda(p)$

• Cost Between Vertex: $\text{cost}(s, t) = \min(\lambda(\pi) | \pi : s \rightarrow t)$

• No Path Cost: $\text{cost}(s, t) = \infty$

Reachable (equivalence relation): $v$ is reachable from $u$ if there is a path from $u$ to $v$

Reachable in $B$ step as Boolean Matrix Multiplication: $C(i, j) = \bigvee_k A(i, k) \land A(k, j)$

• Let $A$ be adjacency matrix of $G$, then $A^k(u, v) = 1 \iff \text{ there is a path } \pi : u \rightarrow v \text{ of length} k \text{ in } G$.

• but boolean matrix multiplication is costly

• Worst Case: $A^* = I + A + A^2 + ... + A^{|V|-1}$

Directed Graph: edge is ordered pair

• out degree: number of edges come out $\text{deg}_{\text{out}}(u) = |\{v | (u, v) \in E\}|$

• in degree: number of edges come in $\text{deg}_{\text{in}}(u) = |\{v | (v, u) \in E\}|$

• strongly connected: $(\forall u, v \in V)(v \text{is reachabble from }u)$

General Graph: allow parallel edges and self-loops

Endpoints: $u, v$ are endpoints of $e = \{u, v\} \in E$. Adjacent: $u, v$ are adjacent when $e = \{u, v\} \in E$. Incident: $u, v$ are incident on $e = \{u, v\} \in E$. Neighbore: $u, v$ are neighbore of $v, u$ respectively when $e = \{u, v\} \in E$. Neighborehood: neighborehood of vertice $u$ is the set of vertices $N(u) = \{v | \{u, v\} \in E\}$ connected to $u$. Degree: degree of $u$ is $|N(u)|$

• $\sum_{u \in V}\text{degree}(u) = 2|E|$

Adjacency Matrix: $A[i,j] = \begin{cases} 1 \text{ if } i, j \text{ are adjacent}\\ 0 \text{ otherwise}\\ \end{cases}$

• $O(1)$ look up, but $n^2$ space (wasteful for sparse graph)

• $\Omega(n)$ to enumerate neighbores

Adjacency List: $|V|$-dimension array each storing its neighbores in chain.

• $\Omega(\text{degree}(u)) = \Omega(n)$ look up $O(m+n)$ space

• $O(\text{degree}(u))$ to enumerate neighbores

Maximum Cut: separate vertice into two groups, making as many edges connected to different group as possible

• Local Search $O((m+n)^2)$ (approximation): color all vertice by 1 color. Then for each vertex, try to switch its color see if increase cut. If not, halt.

## Sutner's Lecture

Graph: equivalent to relation

• Dirrected Graph: $G = \langle{V, E \subseteq V \times V}\rangle$

• source: $\text{src}(e) \in V$ is the source of edge $e$
• target: $\text{trg}(e) \in V$ is the target of edge $e$
• self-loop: $\text{src}(e) = \text{trg}(e)$
• Dirrected Multi-Graph: $G = \langle{V, E, \text{src}, \text{trg}}\rangle$ such that $\text{src}, \text{trg}: E \rightarrow V$ are two maps

• Undirected Graph: $G = \langle{V, E \subseteq V \times V}\rangle$ where $E$ is a set of one or two element (depending on whether self loop)

Isomorphic: Let $G_1 = \langle{V_1, E_1}\rangle, G_2 = \langle{V_2, E_2}\rangle$. $G_1, G_2$ are isomorphic if there is a bijection $f : V_1 \rightarrow V_2$ such that $(u, v) \in E_1 \iff (f(u), f(v)) \in E_2$

Sparse Graph: $|E| \leq |V|^2$

• Sparse Matrix: use pointers to condense matrix and get good performance

Minor: graph $H$ is a minor of $G$ if it can be obtained from $G$ by a sequence of vertex removals.

• edge removal: remove edge only

• edge contraction: remove edge $\{x, y\}$, introduce new vertex $v$ and connect it to the neighbors of $x$ and $y$ (kill multiple edges)

• Obstruction: a minor of the graph that, once find, get the entire graph out of the class

• Every minor-closed family of graphs has a finite obstruction set.
• Planarity: 2 obstruction minors
• Projective Planar Graphs: 35 forbidden minors
• Delta-wye-delta: 18 forbidden minors (no one knows for sure)
• Checking minor is for fixed minor $O(n^2)$ but we don't know the exact constant.

Planar Graph: can be drawned without any edges

• Theorem: a graph is planar iff it does not contain a $K_5$ or a $K_{3, 3}$ as a minor

• Algorithm: Tarjan