I have a question about IBD. Please see the figure below. How many pairs of alleles are IBD for X and Y, or what is the IBD value for X and Y. Is it four (4)? I have seen it to be maximally 2, but then we assume that no inbreeding occurs, right?
An Identical-By-Descent (IBD) value is the number of alleles which are the same because of descent from a common ancestor. Since each (diploid) individual has two alleles for a given (autosomal) gene, the number of them that are IBD with another individual can only be 0, 1, or 2.
In your example, X and Y inherit each of their alleles from A2, so their IBD value is 2. Inbreeding is just an extreme form of descent from a common ancestor; it causes on average greater probability of high IBD values than when comparing less-inbred individuals. See the passage here for more detail.