implemented all graph functions