Text this: An algorithm for maximal flow with gains in a special network