A hypothetical heat engine with no friction, achieving the ideal efficiency:

This engine is reversible, meaning that it can run backwards. Thus in the Carnot cycle heat must not flow from one area to another, as when run in reverse this would violate the second law of thermodynamics (i.e., heat cannot transfer from a colder region to a hotter one). Even if heat is transferred in the two isothermal processes in the cycle, no significant amount of heat flows from one to another as it would be immediately eliminated by doing work. Note that due to the nature of the isothermal process, the Carnot engine is very slow.

Processes of a Carnot engine: … ⇒ isothermal expansion ⇒ adiabatic expansion ⇒ isothermal compression ⇒ adiabatic compression ⇒ …

Note that any point on the PV diagram (and of course the vertices) is a state of the system that can be described using the ideal gas law.