Implemented is_cyclic method in Graph class.