Implemented is_linear method in Graph class.