Every router floods a map of its own links, then each runs Dijkstra independently to compute loop-free shortest paths.
Link-state routing solves a hard problem cleanly: how do thousands of routers, each seeing only its own neighbours, agree on consistent paths across the whole network? The trick is to *separate* two jobs. First, give every router an identical map of the network. Then let each router selfishly compute its own shortest paths on that shared map. Because everyone computes from the same truth, the routes stitch together with no loops. The most widely deployed real-world example is OSPF.
Each router knows only one local fact: which neighbours it connects to and the cost of each link. It packages that fact into a link-state advertisement (LSA) and floods it — passing it to every neighbour, who pass it onward, until every router in the network has a copy. After flooding settles, each router has assembled the same link-state database: a full map of every link and cost.
With an identical map in hand, every router independently runs Dijkstra's algorithm, treating *itself* as the source. It repeatedly settles the closest router not yet finalized, then relaxes that router's neighbours — lowering their tentative distance whenever a cheaper path is found. The result is a shortest-path tree: the cheapest route from this router to every other one.