Fix a bug I introduced while trying to simplify the code.

This version produces correct graphs.