refactored graph-related code (switch from generic type to int)