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

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

I just learned Ford-Fulkerson Algorithm for Maximum Flow Problem with BFS/DFS. I solved one problem from lightoj.com.

But I couldn't find any basic problem to practice the basic algorithm.

If someone can provide me some very basic problem, by practicing them I'll get used to the basic concept & coding also learn something I'll be really very grateful. I've some problems but those are not basic.

Thank You.

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

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

Ford fulkerson's algo is likely not enough to get you through many Max Flow problems (I will let you find out why). Learn edmond karp's algo instead.

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

    I'll be glad if you help me.

    I'll learn it, but I want to solve some problems of this Algorithm first. Just to get more clearer about this and have a better coding skill for this. Thank You.

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

      You can try out the problems in CP3 that are classified in uhunt as Max Flow (you need to type in your UvA username to see this). Those are problems that I would say are basic.

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

        Sorry for disturbing you again. Uhunt I can only find Network Flow. Is this it? Standard Max Flow Problem (Edmonds Karp's) ?They can be solved by Fulkerson? Thank you.

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

          The thing is, you can pass many test cases using ford fulkerson, but a TLE verdict is likely to be all you'll get even if your algo is correct because there is a particular kind of graph that is challenging for ford fulkerson's algo. If you just want to try out the ford fulkerson's algo but don't care about the verdict, you can try solving the problems on uhunt. If you get TLE, that is likely a sign that your algo is correct, but the input has the special graph that I described above.

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

            Can I ask for any easily described resource of edmond karp's tutorial? I learned Fulkerson from Topcoder. Thank You.

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

              Edmond Karp's algo is essentially same as ford fulkerson's algo. Just that the method for finding an augmenting path is BFS instead of DFS.

              Anyway, Edmond Karp's algo is a very well-known algo. You can easily find many research papers and academic presentations on it if you google.

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

                I used BFS to solve Max-Flow. But I can also solve this by DFS. For 15 test cases and 100 nodes and 5000 edges it took 0.020. Lightoj 1153. Is it enough to solve those UVA? Thank You.

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

                Thank You for your help.

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

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=565

Try out some of these problems. You will probably not get them. Struggle with them, and then try to find solutions online.

The biggest thing with flow is figuring out how to construct the graph and motivate the flow to get the answer you want. This is very hard to do at first, but there's a few tricks involved that will get you through many, many problems. When you look up solutions online, some of them will describe somewhat inefficient graphs (say they use 3n nodes instead of only n necessary nodes, or something). See if you can modify the graphs and still get AC, because it will improve your understanding of how to create such graphs.

Flow problems are really hard at first. They get easier, I promise. Honestly, don't worry about coding the actual flow algorithm. Find some template that's good because 90% of the time you won't modify the actual flow algo.

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

Ford-Fulkerson is rather a method — find augmenting paths and fill them while you can also filling with reverse flow if needed, and all max-flow algorithms like Edmond Karp build on this technique by using a good heuristic to find these paths.