Of course, if you are in the center of a network — like C, whose six friends all in turn have many friends — you are much more likely to catch the flu than individuals with the same number of friends but located on the social periphery, like D. So, in the case of flu spreading in a population, it would be best to be Student A. On the other hand, if useful information (about cool classes or hot parties) were spreading through the network, it would be best to be Student C.

We acquire other properties from our friends, in what is known as “peer effects.” The economist Bruce Sacerdote showed that roommates at Dartmouth, who are randomly assigned to live together, affect each other’s grade-point average and the effort put into studying, for better or worse. Other studies have found a correlation between being happy and having happy friends (and the inverse) as well as a likelihood that a student will binge drink if a roommate does.

But something more is going on in social networks. The actual mathematical structure of the social ties also seems to matter. In our lab experiments, we have created artificial networks — by defining ties between research subjects and specifying permissible paths for them to communicate online. When we change the particular arrangement of the social ties within the group, we have been able to affect whether the groups behave altruistically or selfishly — in one exercise, whether the group shared money from a supply we gave them or, conversely, contributed nothing.

Same people, same number of social ties; different social structure, different behavior. An analogy: If you connect carbon atoms one way, they form graphite, which is soft, dark and suitable for a pencil; connected another way, they form diamond, which is hard and clear. Same atoms, different connections, different properties.

To elicit an optimal amount of altruism in the group, there seems to be a sweet spot between rigidly forced and overly fluid connections, both of which foster less altruistic behavior. When research subjects were not allowed to make their own connections or to cut ties to people who bugged them, they behaved less kindly. At the other extreme, when the people to whom they were connected came and went quickly, the group also behaved less kindly — perhaps too much “social fluidity” made the group less appealing to invest in.

Humans are hard-wired for friendship in one final way: We like the company of people we resemble, a property known as homophily. We evolved as a species by preferring those with shared objectives — all the better to coordinate a hunt for a mammoth. But natural selection has equipped us with a taste for similarity at a cost: the loss of new insights and information that lead to innovation.