mincost maxflow appears to work, but is too slow
merged mincostmaxflow