In ospf all areas need to connect to the backbone area or area0 and area0 has to be contiguous. If for some reason area0 becomes discontiguous as shown in above fig:2 or you end up with an edge area that is not connected to area0 as shown in above fig:1 then we can configure virtual links.
While configuring virtual links we need to keep the below two things in mind
1)A virtual link can't go through a stub and
2)And a virtual link can't go through more than one area.
The virtual link will make two ABR's that connect to the same nonbackbone area to build neighborships through that area.
While configuring the virtual link each ABR will use the RID of the other ABR and the area through which the virtual link is passing.
The OSPF messages are packaged inside the unicast IP packets. The IP packet will have the destination IP address of the other end router.
If there are any routers between the two ABR's that create the virtual links they just forward the OSPF packets like any other packet.
After becoming the neighbors the two ABR's will exchange their LSDB's to each other. As a result, both parts of area0 will update themselves with the routes from the other part of area0.
The configuration for the virtual links for the ABR's in the above diagrams is shown below.