isGraphConnected method added