Who owes who money optimization

后端 未结 10 1264
暗喜
暗喜 2020-12-14 02:18

Say you have n people, each who owe each other money. In general it should be possible to reduce the amount of transactions that need to take place. i.e. if X owes Y £4 and

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 02:58

    I think you must remove all cicles reducing edges by minimal edge value and removingedges with value 0. After it you will get graph withouth cicles. I think you must find vertexes, wich have no pointers to them (man's wich owes only others money). This man's must pay money, beacouse there is no one to pay the money for them. So my point is that you must find somehow who they must pay.

提交回复
热议问题