Two cells on a K-map are adjacent when their codes differ in exactly one variable, the same idea as adjacent minterms. Only adjacent cells can share a group, because only then does a variable cancel.
On the map, adjacency looks like this:
- side by side in a row, or directly above or below: adjacent
- at opposite ends of a row or column: adjacent, because the map wraps
- touching only at a corner (diagonal): never adjacent
In an n-variable map every cell has exactly n neighbors, one for each variable you could flip. In a 4-variable map that's 4 neighbors, including any across a wrap.
A quick test without the map: two cells are adjacent if their codes have a hamming distance of 1. Equivalently, XORing the two minterm numbers gives a power of two: 5 ⊕ 7 = 2 (adjacent), but 3 ⊕ 5 = 6 (not adjacent).
Consecutive minterm numbers are often not adjacent. m7 = 0111 and m8 = 1000 differ in all four bits, even though 7 and 8 are next to each other as numbers.
| AB\CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 0m0 | 1m1 | 0m3 | 0m2 |
| 01 | 1m4 | 0m5 | 1m7 | 0m6 |
| 11 | 0m12 | 1m13 | 0m15 | 0m14 |
| 10 | 0m8 | 0m9 | 0m11 | 0m10 |