This is the Dominating Set problem, which is NP-hard, so unless P = NP, there is no polynomial solution for it.
Note that n < 20, so luckily we can still solve it fast enough. For every user 0 ≤ i < n, let's represent its neighborhood by a bitmask b(i) with n bits that has all the bits set that represent users reachable from i via paths of length ≤ 1. We can precompute b(i) in O(n²).
Let's define f(i,m) to be the minimal number of users needed to reach all users represented by the bitmask m, posting only on the walls of users with index ≤ i. We can compute f using the following algorithm:
f(i,m) = ∞ for all i, m
f(0, 0) = 0
f(0, b(0)) = 1
for i = 1 to n - 1:
for m = 0 to 2^n - 1:
f(i, m) = min(f(i, m), f(i - 1, m))
f(i, m | b(i)) = min(f(i, m | b(i)), f(i - 1, m) + 1)
The answer is f(n - 1, 2^n - 1). Runtime: O(n * 2^n)