vectorized findFlowEdges function