added isConnected method to Graph