Rewrote graph printing function.