The affinity relationshipof Earthly Branches is from the relative positions (in the sky) of
the Sun
and the Moon in an old calendar system. Also, all animals in the Chinese
Calendar have a sequence number.

Rat (1) and Cow (2) like each other and generate
the Earth ingredient.

Dragon (5) and Chicken (10)
like each other and generate the Metal ingredient.

Snake (6) and Monkey (9) like each other and generate
the Water
ingredient.

Tiger (3) and Pig (12) like each other and generate
the Wood
ingredient.

Rabbit (4) and Dog(11) like each other and generate
the Fire
ingredient.

Enmity relationship
(Rejection)

Just like the Stem relationship, the enmity
relationship is from
the relative positions of
the elements. The Chinese consider a "face to face" conflict as the enmity relationship.
Wood is in the east and faces Metal in the West. Water is in the north and faces
Fire in the south. They are unlike each other, so they live in different places.
Also, same genders reject each other.

There is an Enmity relationship when the
difference between the animal's sequence numbers is six.