When making a melee attack, you get a +2 flanking bonus if your
opponent is threatened by a character or creature friendly to you on the
opponent's opposite border or opposite corner.
When in doubt about whether two friendly characters flank an
opponent in the middle, trace an imaginary line between the two friendly characters' centers. If the line passes through opposite borders of the
opponent's space (including corners of those borders), then the
opponent is flanked.
Only a creature or character that threatens the defender can help an attacker get a flanking bonus.