What is the potential difference across a disconnected diode? I think potential difference across disconnected diode should be zero but how?

the last graph tells that there is a potential difference between the two ends of a diode. then how can be it zero?
 A: If you take a diode that isn't connected to anything we get the usual depletion layer at the PN junction:

And we get a potential difference generated across the junction. Suppose we now connect the two side of the diode with an external wire, then a second depletion zone develops at the connections with the wire:

And this depletion zone has a potential equal and opposite to the depletion zone at the junction.
So when we first connect the wire there is a transient current while the second depletion zone is building up, but the current stops as soon as the potential across the second zone balances the one across the junction. If we now disconnect the external wire electrons flow through the PN junction and the second depletion zone disappears.
A: Current only flows between two points if there is a potential difference between the points. No current means no pd. The figure you've shown is how the charge distributes at the PN junction, this creates a potential barrier that charge must overcome to cross the barrier, it is not a voltage that can be used to cause current flow. For example, if you were to connect the leads of the diode together then current wouldn't be expected to flow from the conservation of energy.
A: I'm assuming now that what confuses you is that this is not an active element, but still from the picture you would assume that connecting the ends of the diode would create an electrical current because of the potential difference that you see.
To me the confusion always was, how this diode is able to "produce energy" or "current" out of nowhere.
The clue is: If you connect the two ends of the diode, the same thing that happens at the junction of the p-part and the n-part will just happen again: There will be a current from the p-part to the n-part because of the potential-difference, but at the same time there will be a diffusion current because of the different densities of electrons and holes in the p and the n part. After short Time, equilibrium is reached, and thus there will be no more current, but still the same potential difference. 
It would be another case, if you connect both ends of the diode to a conductor material. In that case at the two junctions there will happen the same thing that happens at the p-n-junction. This will bring the potential in the conductor-end-parts to the same level again, and there will be no potential difference. 
A: The charge separation shown in the diagram is true, as far as it goes. Keep in mind that the diagram shows an isolated diode, so the resistance between the ends of the diodes is infinite and no current flows.
The driving mechanism behind the separation of charge is thermal motion of the electrons in the diode. If you were to place a large enough resistor between the ends of the diode, you could in principle get a measurable current at something like the diode voltage. Perpetual motion? Nope. The process of separating the charges will cause the material to become cooler, and if unchecked this process will continue until thermal motion ceases. in other words, you have to heat the diode to get it to work as a generator.
And there's another way to goose the process: shine a light on the diode. Electrons produced by the absorption of photons can, indeed, produce useful amounts of energy - an illuminated diode is neither more nor less than a photovoltaic solar cell.
