I am trying to think of an algorithm such that giving a graph $G(V,E)$, and a weight function $w\colon E \to \mathbb{N}_+$ (which means giving every edge in the graph a positive weight), and a source vertex $S$, the algorithm finds the shortest path between each $v \in V$ and $S$, such that the weight of the path is divided by 3 . (The weight of the path means the sum of all the weights of the edges that are on the path.)
In some solutions, I found that for this problem they built a new auxiliary graph which will "maintain the weight modulo 3" so that when we get from $S$ to any vertex we will be interested in the path that starts and ends with remainder 0 and this is through duplicating the graph to 3 copies which will allow switching between different copies.
I don’t understand how to build such a graph and how it is going to help me with this problem, any help would be appreciated.