Блог пользователя Tanzir5

Автор Tanzir5, история, 8 лет назад, По-английски

I was wondering if there is any way to solve the following problem:

" You are given a network graph. Every edge has two values associated with it: the upper bound of the amount of flow that CAN go through this edge and the lower bound of the amount of flow that MUST go through this edge. If there is no valid way to satisfy lower bound of all the edges, print "Unsolvable" . If there are multiple ways, maximize the amount of flow satisfying the lower bounds and upper bounds. You have to report the maximum amount and also the amount of flows through individual edges. "

I don't know of any online judge that has this problem. It's a random problem that came to my mind.

  • Проголосовать: нравится
  • +25
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

This is known as Maximum Flow with edge demands. You can read about it here. Link

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks. I actually wanted to know if it is possible to print the amount of flow that goes through individual edges in the best solution. I somehow missed that part. I've edited the post.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +12 Проголосовать: не нравится

    That link doesn't work anymore but can be recovered with Wayback Machine. Link

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Tanzir5 (previous revision, new revision, compare).

»
8 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

actually it exists here on codeforces : problem B reactor cooling 2002-2003 Зимние Петрозаводские сборы, Andrew Stankevich Contest 1 (ASC 1)

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks.

    But this problem doesn't ask to maximize the flow. It just wants any solution where we can meet the constraints given.

    • »
      »
      »
      8 лет назад, # ^ |
        Проголосовать: нравится +5 Проголосовать: не нравится

      Since you can already solve lower bounds, you can just add a new super-source connected to the real source via a single edge, and use binary search to determine the maximum possible lower bound on that edge for which a feasible flow still exists.

      • »
        »
        »
        »
        8 лет назад, # ^ |
          Проголосовать: нравится +3 Проголосовать: не нравится

        As far as I know, if lower bounds can be satisfied in any way, then the max flow satisfying that lower bound and the max flow that we get without satisfying any lower bound are both actually equal. That is, satisfying lower bounds does not change the amount of max flow.So there is no need for binary searching. But I had problems with printing the flow going through individual edges in such a solution.

        But your comment has given me an idea about printing the solution. We should at first check if lower bounds can be satisfied.Then we should run normal max flow algorithm on the input graph without any lower bound just to know the maximum flow. Then we should add a new super sink and add an edge from the sink to the super sink. The lower bound on that edge should be equal to the maximum flow. After doing this, if we run the algorithm for lower bound on the modified graph with all the lower bound constraints and then print the flow for individual edges, this should work I guess.

        Thanks. :D

        • »
          »
          »
          »
          »
          8 лет назад, # ^ |
            Проголосовать: нравится +5 Проголосовать: не нравится

          If I understand your first paragraph correctly then I think you're mistaken, actually satisfying lower bounds of flow on edges can make the max flow less than without satisfying them.

          Here's an example (each row describe an edge and has four integers "from", "to", "lower bound", "upper bound"): compute max flow from vertex 1 to 4

          1 2 0 1
          1 3 0 1
          2 4 0 1
          3 4 0 1
          2 3 1 1
          

          max flow not satisfying lower bounds is 2 while max flow satisfying it is 1

          • »
            »
            »
            »
            »
            »
            8 лет назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            Oh. I was wrong then. So we do need to binary search on the maximum flow. Thanks.

    • »
      »
      »
      8 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

      Another problem, which requires you to maximize the flow, is Captain America. This one is not as straightforward, though, so if you just want to test your implementation then you might want to take a look at the editorial.

      And here is my solution, in case it helps: 19731371

»
8 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

"No online judge has this problem" LOL, this is like an introductory network flow problem.

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Tanzir5 (previous revision, new revision, compare).