The Calculus of Friendship