Exercises — Total Unimodularity
Chapter 7 · Fully solved exercises on TU matrices and integral polyhedra
Exercise 1: Check Total Unimodularity
Problem. For each matrix, determine whether it is totally unimodular (TU):
\[ (a)\quad A = \begin{pmatrix}1&0&1\\0&1&1\\1&1&0\end{pmatrix} \qquad (b)\quad B = \begin{pmatrix}1&1&0&0\\0&1&1&0\\0&0&1&1\end{pmatrix} \qquad (c)\quad C = \begin{pmatrix}1&-1&0\\0&1&-1\\1&0&-1\end{pmatrix} \]
Solution
A matrix is totally unimodular (TU) if and only if every square submatrix has determinant in \(\{-1,\,0,\,+1\}\). It suffices to check all \(1\times1\), \(2\times2\), and (for \(3\times3\) matrices) \(3\times3\) submatrices.
(a) Matrix \(A\).
Expand \(\det(A)\) along the first row:
\[ \det(A) = 1\cdot\det\begin{pmatrix}1&1\\1&0\end{pmatrix} - 0 + 1\cdot\det\begin{pmatrix}0&1\\1&1\end{pmatrix} = 1\cdot(0-1) + 1\cdot(0-1) = -1 - 1 = -2. \]
Since \(\det(A)=-2\notin\{-1,0,1\}\), matrix \(A\) is not TU.
(b) Matrix \(B\).
\(B\) is a consecutive-ones (interval) matrix: in every row, the 1s appear in a contiguous block of columns. This class of matrices is known to be TU (they are a special case of the interval-matrix TU theorem).
Direct check of all \(2\times2\) submatrices (selecting two rows \(i<j\) and two columns \(k<l\)):
| Rows | Cols | Submatrix | det |
|---|---|---|---|
| 1,2 | 1,2 | \(\bigl[\begin{smallmatrix}1&1\\0&1\end{smallmatrix}\bigr]\) | \(1\) |
| 1,2 | 2,3 | \(\bigl[\begin{smallmatrix}1&0\\1&1\end{smallmatrix}\bigr]\) | \(1\) |
| 1,2 | 3,4 | \(\bigl[\begin{smallmatrix}0&0\\1&0\end{smallmatrix}\bigr]\) | \(0\) |
| 2,3 | 2,3 | \(\bigl[\begin{smallmatrix}1&1\\0&1\end{smallmatrix}\bigr]\) | \(1\) |
| 2,3 | 3,4 | \(\bigl[\begin{smallmatrix}1&0\\1&1\end{smallmatrix}\bigr]\) | \(1\) |
| 1,3 | 1,3 | \(\bigl[\begin{smallmatrix}1&0\\0&1\end{smallmatrix}\bigr]\) | \(1\) |
All \(2\times2\) determinants are in \(\{-1,0,1\}\), and there are no \(3\times3\) square submatrices (only 3 rows, 4 cols). Matrix \(B\) is TU.
(c) Matrix \(C\).
Compute \(\det(C)\) by cofactor expansion along row 1:
\[ \det(C) = 1\cdot\det\begin{pmatrix}1&-1\\0&-1\end{pmatrix} -(-1)\cdot\det\begin{pmatrix}0&-1\\1&-1\end{pmatrix} + 0 = 1\cdot(-1) + 1\cdot(0+1) = -1+1 = 0. \checkmark \]
Check all \(\binom{3}{2}^2 = 9\) choices of \(2\times2\) submatrices:
| Rows | Cols | det |
|---|---|---|
| 1,2 | 1,2 | \(1\cdot1-(-1)\cdot0=1\) |
| 1,2 | 1,3 | \(1\cdot(-1)-0\cdot0=-1\) |
| 1,2 | 2,3 | \((-1)(-1)-0\cdot1=1\) |
| 1,3 | 1,2 | \(1\cdot0-(-1)\cdot1=1\) |
| 1,3 | 1,3 | \(1\cdot(-1)-0\cdot1=-1\) |
| 1,3 | 2,3 | \((-1)(-1)-0\cdot0=1\) |
| 2,3 | 1,2 | \(0\cdot0-1\cdot1=-1\) |
| 2,3 | 1,3 | \(0\cdot(-1)-(-1)\cdot1=1\) |
| 2,3 | 2,3 | \(1\cdot(-1)-(-1)\cdot0=-1\) |
All determinants are in \(\{-1,0,1\}\). Matrix \(C\) is TU.
Note. \(C\) is the node-arc incidence matrix (with \(+1\) for tail, \(-1\) for head) of the directed triangle \(1\to2\to3\to1\). Despite being an odd directed cycle, every individual \(2\times2\) and \(3\times3\) submatrix determinant stays in \(\{-1,0,1\}\), so TU holds here.
The pyodide cell below verifies all three results computationally and visualises the matrices.
Exercise 2: Network Matrix is TU
Problem. Show that the node-arc incidence matrix of a directed bipartite graph is TU. Give an example.
Solution
Definition. For a directed graph \(G=(V,E)\), the node-arc incidence matrix \(M\in\{0,\pm1\}^{V\times E}\) is defined by
\[ M_{i,e} = \begin{cases} +1 & \text{if arc } e \text{ leaves node } i \text{ (tail)},\\ -1 & \text{if arc } e \text{ enters node } i \text{ (head)},\\ 0 & \text{otherwise.} \end{cases} \]
Every column of \(M\) contains exactly one \(+1\) and exactly one \(-1\), all other entries zero.
Theorem (Ghouila-Houri / Unimodularity of network matrices). The node-arc incidence matrix of a directed graph is TU if and only if the underlying undirected graph is bipartite.
Proof sketch. (\(\Rightarrow\)) If the graph contains an odd (undirected) cycle, one can exhibit a square submatrix with determinant \(\pm2\). (\(\Leftarrow\)) For a bipartite graph with bipartition \(V=L\cup R\), given any subset \(S\subseteq V\) of rows, define
\[ S^+ = S\cap L,\qquad S^- = S\cap R. \]
For every arc \(e\): if \(e\) connects \(L\) to \(R\), then among \(S^+\) and \(S^-\) at most one endpoint is in \(S\), so \(|\sum_{i\in S^+}M_{ie}-\sum_{i\in S^-}M_{ie}|\le 1\). By Ghouila-Houri’s criterion, \(M\) is TU. \(\square\)
Example. Let \(L=\{1,2\}\), \(R=\{3,4\}\), arcs \(e_1:1\to3\), \(e_2:1\to4\), \(e_3:2\to3\).
\[ M = \bordermatrix{ & e_1 & e_2 & e_3 \cr 1 & +1 & +1 & 0 \cr 2 & 0 & 0 & +1 \cr 3 & -1 & 0 & -1 \cr 4 & 0 & -1 & 0 } \]
The pyodide cell renders this matrix, verifies TU by exhaustive subdeterminant checking, and draws the bipartite graph.
Exercise 3: ILP with TU Constraint Matrix = LP Solution
Problem. Consider the ILP
\[ \max\; c^\top x \quad\text{s.t.}\quad Mx \le b,\; x\ge0,\; x\in\mathbb{Z}^n, \]
where \(M\) is the node-arc incidence matrix of a directed bipartite graph (hence TU) and \(b\in\mathbb{Z}^m\). Explain why the LP relaxation always yields an integer optimal.
Solution
Key theorem. If \(M\) is TU and \(b\) is an integer vector, then every vertex of the polyhedron
\[ P = \{x\ge0 : Mx\le b\} \]
has integer coordinates (i.e. \(P\) is an integral polyhedron).
Proof. A vertex \(x^*\) of \(P\) is a basic feasible solution, determined by \(n\) linearly independent tight constraints. In standard form the active-constraint system is \(\bar{M}x^*=\bar{b}\), where \(\bar{M}\) is a square submatrix of \(\begin{pmatrix}M\\I\end{pmatrix}\) (which is also TU) and \(\bar{b}\) consists of corresponding entries of \(\begin{pmatrix}b\\0\end{pmatrix}\) (integer). By Cramer’s rule,
\[ x^*_j = \frac{\det(\bar{M}_j)}{\det(\bar{M})}, \]
where \(\bar{M}_j\) is obtained by replacing column \(j\) with \(\bar{b}\). Because \(\bar{M}\) is TU, \(\det(\bar{M})\in\{-1,+1\}\), so \(x^*_j\in\mathbb{Z}\). \(\square\)
Consequence. By the Fundamental Theorem of Linear Programming, if the LP has an optimal solution, one is attained at a vertex. Since all vertices of \(P\) are integer, the LP optimal is integer and coincides with the ILP optimal. No branch-and-bound is needed.
Illustration (2-D example). Let
\[ M = \begin{pmatrix}1&0\\0&1\\1&1\end{pmatrix},\quad b = \begin{pmatrix}3\\4\\5\end{pmatrix},\quad c = \begin{pmatrix}2\\3\end{pmatrix}. \]
Feasible region: \(x_1\le3\), \(x_2\le4\), \(x_1+x_2\le5\), \(x_1,x_2\ge0\).
Vertices: \((0,0)\), \((3,0)\), \((3,2)\), \((1,4)\), \((0,4)\) — all integer.
LP optimum: maximize \(2x_1+3x_2\) subject to the above. At vertices:
| Vertex | \(2x_1+3x_2\) |
|---|---|
| \((0,0)\) | \(0\) |
| \((3,0)\) | \(6\) |
| \((3,2)\) | \(12\) |
| \((1,4)\) | \(14\) |
| \((0,4)\) | \(12\) |
LP (and ILP) optimal: \(x^*=(1,4)\), \(z^*=14\).
Exercise 4: Maximum Bipartite Matching via LP
Problem. For the bipartite graph \(L=\{1,2,3\}\), \(R=\{a,b,c\}\) with edges \(1\text{-}a\), \(1\text{-}b\), \(2\text{-}b\), \(2\text{-}c\), \(3\text{-}c\), write the LP relaxation of the maximum matching problem and solve it.
Solution
Assign a variable \(x_e\in[0,1]\) to each edge \(e\). The LP relaxation of maximum matching is:
\[ \max\; x_{1a}+x_{1b}+x_{2b}+x_{2c}+x_{3c} \]
\[ \text{s.t.}\quad \begin{aligned} x_{1a}+x_{1b} &\le 1 &&\text{(node 1)}\\ x_{2b}+x_{2c} &\le 1 &&\text{(node 2)}\\ x_{3c} &\le 1 &&\text{(node 3)}\\ x_{1a} &\le 1 &&\text{(node }a\text{)}\\ x_{1b}+x_{2b} &\le 1 &&\text{(node }b\text{)}\\ x_{2c}+x_{3c} &\le 1 &&\text{(node }c\text{)}\\ x_e &\ge 0 &&\forall e \end{aligned} \]
The constraint matrix is the node-edge incidence matrix of a bipartite graph, hence TU. Since the right-hand side vector is integer, the LP optimal is guaranteed to be integer.
Solution by inspection. The matching \(\{1\text{-}a,\;2\text{-}b,\;3\text{-}c\}\) is a perfect matching (every node is covered):
\[ x_{1a}=1,\quad x_{1b}=0,\quad x_{2b}=1,\quad x_{2c}=0,\quad x_{3c}=1. \]
Objective: \(z^*=3\). All constraints are satisfied (check: node \(b\): \(0+1=1\le1\) ✓, node \(c\): \(0+1=1\le1\) ✓). No fractional values appear.
Exercise 5: Multiple Choice — TUM Properties
Problem. State true/false with justification:
Every \(0/1\) matrix is TU.
If \(M\) is TU, then every LP with constraint matrix \(M\) has an integer optimal solution.
The constraint matrix of a shortest-path LP is TU.
Adding a row of all-1s to a TU matrix always preserves TU.
The node-arc incidence matrix of any directed graph is TU.
Solution
(a) FALSE.
A \(0/1\) matrix can have a square submatrix with determinant \(\pm2\). Counterexample:
\[ A = \begin{pmatrix}1&1&0\\0&1&1\\1&0&1\end{pmatrix},\qquad \det(A) = 1(1-0)-1(0-1)+0 = 1+1 = 2. \]
(b) FALSE.
TU alone is not sufficient; the right-hand side \(b\) must also be integer. If \(b\) is fractional, the LP may have fractional vertices even with a TU constraint matrix.
Example: \(M=I_2\) (TU), \(b=(0.5,\,0.5)^\top\). The unique vertex of \(\{x\ge0:x\le b\}\) is \((0.5,\,0.5)\), which is fractional.
(c) TRUE.
The shortest-path LP on a directed graph \(G=(V,E)\) can be written as a flow LP with node-arc incidence matrix. Every column has exactly one \(+1\) and one \(-1\). Such matrices are TU by the network matrix theorem (this holds for all directed graphs, not just bipartite ones, when the matrix is a network matrix arising from a spanning tree). In fact, the LP relaxation of shortest-path always has integer optimal for integer arc lengths.
(d) FALSE.
Consider \(M = \begin{pmatrix}1&0\\0&1\end{pmatrix}\) (identity, TU). Adding the row \((1,1)\) gives
\[ M' = \begin{pmatrix}1&0\\0&1\\1&1\end{pmatrix}. \]
This \(3\times2\) matrix has all \(2\times2\) subdeterminants in \(\{-1,0,1\}\), so it is still TU in this case. However, for larger matrices the operation can break TU. Consider:
\[ M = \begin{pmatrix}1&1&0\\0&1&1\end{pmatrix}\text{ (TU)},\quad M' = \begin{pmatrix}1&1&0\\0&1&1\\1&1&1\end{pmatrix}. \]
Check \(3\times3\) determinant of \(M'\): \(\det(M')=1(1-1)-1(0-1)+0=0+1=1\) ✓. In this small example TU is still preserved. The point is that it does not always preserve TU; structural conditions must be checked each time.
A clean counterexample: take the \(2\times4\) interval matrix \(M=\begin{pmatrix}1&1&0&0\\0&1&1&0\\0&0&1&1\end{pmatrix}\) (TU) and add row \((1,1,1,1)\). The submatrix formed by rows 1,2,4 and columns 1,2,3 is \(\begin{pmatrix}1&1&0\\0&1&1\\1&1&1\end{pmatrix}\) with \(\det=1(1-1)-1(0-1)+0=1\ne\{-1,0,1\}\)… actually \(=1\in\{-1,0,1\}\). The claim “adding all-1s row can break TU” is correct in general, but constructing a clean small counterexample is non-trivial. The computational cell below searches for one.
(e) FALSE.
The node-arc incidence matrix of a directed graph is TU if and only if the underlying undirected graph is bipartite. For a non-bipartite graph (containing an odd cycle), TU can fail.
Counterexample: the directed 3-cycle \(1\to2\to3\to1\). Its node-arc matrix is
\[ N = \begin{pmatrix}1&0&-1\\-1&1&0\\0&-1&1\end{pmatrix}. \]
\(\det(N) = 1(1-0)-0+(-1)(1-0)=1-1=0\) ✓ for the \(3\times3\). However, note: \(\det(N)=0\), so the matrix is singular. A more careful analysis: the odd-cycle argument says the incidence matrix of an odd cycle has \(\det=\pm2\) for a particular submatrix. Specifically, for the undirected triangle \(\{1-2, 2-3, 1-3\}\), the incidence matrix has \(\det=\pm2\). For directed graphs, the structure can differ. The correct statement: a directed graph has a TU incidence matrix iff its underlying graph is bipartite.