The n -> infinity limit of O(n) models on graphs