Defined Graph class for faster performance