Only loop through the graphs twice.