much more efficient strategy for constructing graphs