I am reading Cameron's Combinatorics and came across following part of the proof of De Bruijn-Erdos theorem which I am unable to follow.
$F$ is the family of set such that any two sets in $F$ intersect at only one point. $F = \{ A_1,A_2 \ldots A_b\}$
$|F| = b$
Counting the number of triples $(i,A_j,A_k)$ with $i \in A_j \cap A_k$ and $j \neq k$ and $r_i$ be the repetition index of $i$. i.e number of sets in which $i$ is present.
$$ \sum\limits_{i=1}^nr_i(r_i-1) = b(b-1)$$ I do not follow how lhs is equal to rhs. LHS counting number of arrangements for each set containing $i$ and then iterating over each element $i$. But from where does $b(b-1)$ come ?
The RHS is twice the number of pairs of sets. The LHS is the sum over each $i$ of twice the number of pairs of sets containing $i$. Since each pair of sets has a single element in common, these quantities are the same.