In a nutshell
Link-state routing gives every router an identical map of the network. Each router floods a description of its own links to all the others, so everyone builds the same database. Then each independently runs Dijkstra's shortest-path algorithm on that map, producing routes that are consistent and free of loops.