Hello. The bfs article says that
Finding the shortest path in a 0-1-graph (i.e., a weighted graph, but with weights equal to only 0 or 1): modifying the search in width is enough: if the current edge is of zero weight, and the distance to some vertex is improved, then we add this vertex not to the end, but to the beginning of the queue.
How to check the improvement distance to some vertex for rational asymptotics, and how to continue to work with it, because that peak, the distance to which improved could be “set on fire” almost at the very beginning, and then you have to go all over again.
UPDATE
Tried to go the way of another article . The question arises: if there are edges from vertex 1-2 (weight 1) and 1-3 (weight 0) and 3-2 (weight 0) and 2-1 (weight 0), then the algorithm from vertex 1 will put dist 2 = 1; dist [3] = 0; but from 3 to 2 can not go, because it is used. What to do?