We introduce a novel mathematical approach to investigating the spread and control of communicable infections in closed communities. Mycoplasma pneumoniae is a major cause of bacterial pneumonia in the United States. Outbreaks of illness attributable to mycoplasma commonly occur in closed or semi-closed communities. These outbreaks are difficult to contain because of delays in outbreak detection, the long incubation period of the bacterium, and an incomplete understanding of the effectiveness of infection control strategies. Our model explicitly captures the patterns of interactions among patients and caregivers in an institution with multiple wards. Analysis of this contact network predicts that, despite the relatively low prevalence of mycoplasma pneumonia found among caregivers, the patterns of caregiver activity and the extent to which they are protected against infection may be fundamental to the control and prevention of mycoplasma outbreaks. In particular, the most effective interventions are those that reduce the diversity of interactions between caregivers and patients.