Using Directed Graphs to form multivariate recurrence relations
There are items comprising of red cubes, blue cubes, and balls; how many ways can 3 red cubes, 4 blue cubes and 8 balls be arranged in a line so that:
- No three cubes are consecutive
- No three balls are consecutive
- No two red cubes are next to one another
- No two blue cubes are next to one another
How do we go about finding a general formula for \(r\) red cubes, \(b\) blue cubes and \(c\) balls ?
The answer lies in forming a directed graph / Finite Automaton, as we have seen it in one of the previous posts.
Instead of filling in the number of ways, we use the variable names as weights for the valid transitions.
Hence, we can directly solve for the general case by using the following adjacency matrix:
which is for the constraints that there's no \(RR, BB, RBR, BRB\) or \(CCC\).
Therefore, for 15 items, we compute
and extract \([c^8 b^4 r^3]\) from the sum of the first row, which is \(11394\).
We may also compute the characteristic polynomial of the matrix to get the structure of its multivariate recurrence relation:
which is just like the characteristic equation of a recurrence relation, which is:
and set the required boundary conditions.
Computing the regular expression from the minimized DFA gives us the following multivariate generating function:
Reference: