Ledge is a narrow horizontal surface/shelf projecting from a wall, cliff, other surface. Edge is the outside limit of a surface.
So, you could have the edge of a ledge.
You can get onto a window ledge.
You can climb onto a ledge jutting out from a cliff.
But if you are on top of the cliff, your Mom would say: "Don't go near the edge" - this is the outermost part of the top of the mountian. Any further, and you would fall.
You can have the edge of a cup. Or of a bed.
Hope that assists