I am looking to calculate the cells along a stream network from starting points to a maximum distance and stopping points. I need something like r.cost in GRASS (https://grass.osgeo.org/grass75/manuals/r.cost.html), the only difference is that I need an algorithm capable to follow the stream network topology (without distinguishing between upstream and downstream). The problem is that r.cost only consider contiguous cells, but with streams in raster format, it is possible that contiguous cells are not really connected due to resolution issues, specially at river junctions.
In the picture, there is an example of issues with r.cost. The red point is a starting point, black and gray cells correspond to two different rivers originally connected only at the junction, but spatially contiguous in more points in raster format. Any solution in GRASS or SAGA?