The routers in the same area use the link-state database and SPF algorithm to build the SPF tree. For example, in the figure below R1 build the SPF tree using the link-state information from all other routers. To start, the SPF algorithm read the router’s LSP to recognize networks and also the costs of the link.
In the first step, R1 identifies its directly connected networks and the costs of the network. After identifying the directly connected network, the R1 begin identifying unknown networks from R2 and R3. Then the SPF algorithm calculates the shortest paths to reach each individual network.
The SPF algorithm then calculates the shortest paths to reach each individual network. Each router in the area builds its own SPF tree separately from all other routers. To make sure accurate routing, the link-state databases used to build those trees must be identical on all routers.