Is there a way to determine how two characters are related?
Two characters are considered related for the sake of the inbreeding warning if they share a common ancestor up to their grand-grand-parents. So you should look at the character screens of the four parents and see if their parents and grandparents look similar. When there are any people listed on both sides (not necessarily in the same generation!), the game considers the characters related.
For example, the grandparents of the left person are the grand-grand parents of the right person:
In this case I am looking at the character screens of their respective mothers, but to make sure you would also need to compare the fathers side and each others father with each others mother. A convenient way to perform that comparison is to temporarily "pin" those 4 characters (icon in the upper right corner of the interaction menu). You now have them in the outliner and can switch between them with a single click.
But keep in mind that the fatherhood information you see on the character screens is the official version. When you let your spymaster spend a while "finding secrets" in various courts, you will notice just how frequent adultery is in the game. While the motherhood is reliable (at least I did not discover any "switched at birth" scenarios yet), the fatherhood information should be seen with a grain of salt. So "They are related" should be read as "They appear to be related". This of course can also mean the opposite: When two characters share a male ancestor due to an affair and your character does not know that, then the game won't give you a warning.