# 2. Methodical guidelines / Методичні вказівки This section is **self-contained**: it collects the theory needed for the theme — graphs and their adjacency matrices, and vertex/edge colouring — together with the techniques used to solve the tasks in [3classroom.md](3classroom.md). For fuller treatment see [Lecture 10](../../Lectures/CDM-L10.md), §10.6–10.12. ## 2.1 Graphs, degrees, and kinds of edge A **graph** $G=(V,E)$ is a set of **vertices** $V$ and a set of **edges** $E$, each edge joining two vertices. The kinds we meet in this class: - an **undirected** edge $\{u,v\}$ has no direction; a **directed** edge (an **arc**) $(u,v)$ points from $u$ to $v$; - a **loop** is an edge from a vertex to **itself**; - **parallel** (or **multiple**) edges join the **same** pair of vertices; a graph that allows loops and parallel edges is a **multigraph**. A graph with neither is **simple**. The **degree** $\deg(v)$ is the number of edge-ends at $v$ (a loop counts **twice**). In a digraph the **out-degree** $\deg^{+}(v)$ counts arcs leaving $v$ and the **in-degree** $\deg^{-}(v)$ counts arcs entering. The largest degree in $G$ is $\Delta(G)$; a set of pairwise-adjacent vertices is a **clique**, and the size of the largest one is $\omega(G)$. ## 2.2 The adjacency matrix Number the vertices $v_1,\dots,v_n$. The **adjacency matrix** $A=[a_{ij}]$ is the $n\times n$ table with $$a_{ij} = \bigl(\text{number of edges/arcs between } v_i \text{ and } v_j\bigr).$$ Reading a matrix, four features are immediate: - **Directed or undirected?** For an **undirected** graph $A$ is **symmetric** ($a_{ij}=a_{ji}$): the picture above the diagonal mirrors the picture below. If $A$ is **not** symmetric the graph is **directed**. - **Loops** sit on the **diagonal**: $a_{ii}$ is the number of loops at $v_i$. (Here a loop counts **once** on the diagonal; some texts count it as $2$ — see the note in [main.md](main.md).) - **Parallel edges** show up as entries **greater than $1$**: $a_{ij}=3$ means three edges between $v_i$ and $v_j$. - **Degrees.** For an undirected graph the **$i$-th row sum equals $\deg(v_i)$** (a loop, counted once in $a_{ii}$, must be added a second time to match the "loop counts twice" rule for degree). For a digraph the **row sum** is the out-degree $\deg^{+}(v_i)$ and the **column sum** is the in-degree $\deg^{-}(v_i)$. *Example.* The symmetric matrix (rows/cols $A,B,C,D$) | | $A$ | $B$ | $C$ | $D$ | |:--:|:--:|:--:|:--:|:--:| | $A$ | 0 | 1 | 0 | 1 | | $B$ | 1 | 0 | 1 | 0 | | $C$ | 0 | 1 | 0 | 1 | | $D$ | 1 | 0 | 1 | 0 | is symmetric with zero diagonal, so it is an **undirected**, loop-free, simple graph; the $1$s give the edges $AB, AD, BC, CD$ — a $4$-cycle. ## 2.3 Drawing a graph from its adjacency matrix 1. **Place** the $n$ vertices (a convenient layout — a circle or a square — keeps edges from crossing needlessly). 2. **Decide directed vs. undirected** from the symmetry of $A$. 3. **Off-diagonal entries:** for each $a_{ij}$ (with $i1$); add diagonal loops; verify degrees against row (and column) sums. - **Chromatic number $\chi$:** find the largest clique for a **lower** bound; colour greedily (hardest vertices first) for an **upper** bound; when the two meet you are done. A triangle already forces $\chi\ge 3$; no odd cycle means $\chi\le 2$. - **Chromatic index $\chi'$:** start at $\Delta$; try to build a $\Delta$-edge-colouring (class 1). If it is forced higher — by Vizing to $\Delta+1$, or by the counting bound $\lceil |E|/\lfloor n/2\rfloor\rceil$ for a dense multigraph — say so.