You've the right idea. Yuval's comment provides the missing trick. Here is the algorithm that connects the dots.
- For each pipe $i$ with $A_i$ and $B_i$ from vertex $u$ to vertex $v$, we add an edge of weight $\log(B_i/A_i)$ from $u$ to $v$. TheLet $G$ be the graph with the given $n$ vertices with theand $m$ new edges just added. It is the new graph you were thinking of. Name it $G$.
- Apply Bellman–Ford algorithm with $s$ as the source to detect whether there is a negative-weight cycle in $G$ reachable from $s$.
- If there is, it is possible for $A$ to lead $B$ through a sequence of pipes starting from $s$ so that $A$ gets infinitely larger than $B$. Otherwise, no.
The idea is that the sum of weights along a walk in $G$ corresponds to the logarithm of the change of ratios of $B$'s height to $A$'s height when $A$ and $B$ have walked that walk. A negative-weight cycle means the ratio of $B$'height's height to $A$'s height becomes smaller when both $A$ and $B$ have walked that cycle once.
The algorithm runs in $O(mn)$ time.