GithubHelp home page GithubHelp logo

odubno / ford-fulkerson-max-flow Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 6.0 14 KB

Python code for finding Max Flow in a directed graph.

Python 100.00%
maxflow maxflow-mincut ford-fulkerson ford-fulkerson-algorithm columbia-university bfs-algorithm bfs breadth-first-search bipartite bipartite-graphs

ford-fulkerson-max-flow's People

Contributors

odubno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ford-fulkerson-max-flow's Issues

Error in augmenting flow calculation

Hi!

I'm using this (with credit) for a benchmarking assignment and I noticed a bug in augmenting flow calculation.

Because flow_path is created as a zip it's an iterable.
This means that in augment_flow, after being read for bottleneck calculation, flow_path is emptied and the for loop that would actually augment the path runs over an empty iterator and halts immediately.
An easy fix is to list the zip before calling augment_flow

flow_path = zip(path[:-1], path[1:])

...
bottleneck = min([graph[u][v]['capacity'] for u, v in flow_path])
for u, v in flow_path:
updated_capacity = graph.edge[u][v]['capacity'] - bottleneck

I'm just leaving this here to clear confusion for future people

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.