Graph main code