Raw

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. For fuller treatment see Lecture 10, §10.6–10.12.

2.1 Graphs, degrees, and kinds of edge

A graph G=(V,E)G=(V,E) is a set of vertices VV and a set of edges EE, each edge joining two vertices. The kinds we meet in this class:

  • an undirected edge {u,v}\{u,v\} has no direction; a directed edge (an arc) (u,v)(u,v) points from uu to vv;
  • 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)\deg(v) is the number of edge-ends at vv (a loop counts twice). In a digraph the out-degree deg+(v)\deg^{+}(v) counts arcs leaving vv and the in-degree deg(v)\deg^{-}(v) counts arcs entering. The largest degree in GG is Δ(G)\Delta(G); a set of pairwise-adjacent vertices is a clique, and the size of the largest one is ω(G)\omega(G).

2.2 The adjacency matrix

Number the vertices v1,,vnv_1,\dots,v_n. The adjacency matrix A=[aij]A=[a_{ij}] is the n×nn\times n table with

aij=(number of edges/arcs between vi and vj).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 AA is symmetric (aij=ajia_{ij}=a_{ji}): the picture above the diagonal mirrors the picture below. If AA is not symmetric the graph is directed.
  • Loops sit on the diagonal: aiia_{ii} is the number of loops at viv_i. (Here a loop counts once on the diagonal; some texts count it as 22 — see the note in main.md.)
  • Parallel edges show up as entries greater than 11: aij=3a_{ij}=3 means three edges between viv_i and vjv_j.
  • Degrees. For an undirected graph the ii-th row sum equals deg(vi)\deg(v_i) (a loop, counted once in aiia_{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+(vi)\deg^{+}(v_i) and the column sum is the in-degree deg(vi)\deg^{-}(v_i).

Example. The symmetric matrix (rows/cols A,B,C,DA,B,C,D)

AA BB CC DD
AA 0 1 0 1
BB 1 0 1 0
CC 0 1 0 1
DD 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,CDAB, AD, BC, CD — a 44-cycle.

2.3 Drawing a graph from its adjacency matrix

  1. Place the nn vertices (a convenient layout — a circle or a square — keeps edges from crossing needlessly).
  2. Decide directed vs. undirected from the symmetry of AA.
  3. Off-diagonal entries: for each aija_{ij} (with i<ji<j if undirected) draw aija_{ij} edges between viv_i and vjv_j — a single line, or parallel lines when the entry exceeds 11. For a digraph draw an arrow vivjv_i\to v_j for aija_{ij} and a separate arrow vjviv_j\to v_i for ajia_{ji}.
  4. Diagonal entries: draw aiia_{ii} loops at viv_i.
  5. Check by reading the degrees back off the rows (and columns, for a digraph).

2.4 Vertex colouring and the chromatic number

A proper vertex colouring assigns a colour to every vertex so that adjacent vertices get different colours. The chromatic number χ(G)\chi(G) is the fewest colours a proper colouring can use. (Loops make proper colouring impossible, and parallel edges do not matter — so χ\chi depends only on the simple graph underneath.)

Two bounds trap χ\chi:

  • Lower bound — a clique. In a clique of size kk all kk vertices are mutually adjacent, so they need kk distinct colours:  χ(G)ω(G)\ \chi(G)\ge\omega(G). In particular a single triangle forces χ3\chi\ge 3.
  • Upper bound — greedy. Colouring vertices one at a time, each has at most Δ\Delta already-coloured neighbours, so one of Δ+1\Delta+1 colours is always free:  χ(G)Δ(G)+1\ \chi(G)\le\Delta(G)+1.

Landmark values: χ=1\chi=1 iff there are no edges; χ(Kn)=n\chi(K_n)=n; and χ(G)2\chi(G)\le 2 iff GG is bipartite iff GG has no odd cycle. Hence an even cycle has χ=2\chi=2 and an odd cycle has χ=3\chi=3. To prove χ(G)=k\chi(G)=k: exhibit a kk-colouring (so χk\chi\le k) and a reason it cannot be done with fewer, usually a clique of size kk (so χk\chi\ge k).

2.5 Edge colouring and the chromatic index

A proper edge colouring colours the edges so that edges sharing a vertex get different colours; the fewest colours is the chromatic index χ(G)\chi'(G). Equivalently, each colour class is a matching (a set of edges with no common endpoint).

  • Lower bound — the busiest vertex. The Δ\Delta edges at a maximum-degree vertex pairwise meet there, so all need different colours:  χ(G)Δ(G)\ \chi'(G)\ge\Delta(G).
  • Vizing’s theorem. For a simple graph,  χ(G){Δ, Δ+1}\ \chi'(G)\in\{\Delta,\ \Delta+1\}. Graphs meeting the lower value are class 1; those needing Δ+1\Delta+1 are class 2. (For a multigraph the top can rise: χΔ+μ\chi'\le\Delta+\mu, where μ\mu is the largest edge multiplicity.)
  • A counting bound. A colour class is a matching, so it has at most n/2\lfloor n/2\rfloor edges; hence  χ(G)E/n/2\ \chi'(G)\ge\lceil |E|/\lfloor n/2\rfloor\rceil. This is what pushes a small, edge-heavy multigraph above Δ\Delta.

To prove χ(G)=k\chi'(G)=k: exhibit a kk-edge-colouring and give a reason fewer is impossible (Δ\Delta, or the counting bound).

2.6 Working checklist

  • Matrix → graph: check symmetry (directed or not); place the vertices; draw off-diagonal edges (parallel lines / arrows for entries >1>1); 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 χ3\chi\ge 3; no odd cycle means χ2\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 Δ+1\Delta+1, or by the counting bound E/n/2\lceil |E|/\lfloor n/2\rfloor\rceil for a dense multigraph — say so.

Practical/Practical5/2method.md · 6.4 KB · updated 2026-07-31 21:51