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

Автор orchidmajumder, 11 лет назад, По-английски

Hi,

I want to ask that while initializing the potential array for all the nodes in min cost max flow (edmond karp +djikstra potential method) should I initialize all with zero like what is described in the network flow book by ahuja(same is done also in egor's code) or should I run a bellman ford to set those initial values like what's described in topcoder tutorial min Cost Max Flow successive shortest path algorithm???
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

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

That depends on whether your graph contains negative cost edges from the start or not. If it does then you must run Bellman-Ford (or another single source shortest path distance algorithm capable of handling negative edges) and set the potentials accordingly. If it doesn't then there's no need to run an initial Bellman-Ford, although there's no harm in doing it (apart from some extra runtime and code).