Generating graphs that approach a prescribed modularity