An open API service indexing awesome lists of open source software.

https://github.com/simon-gardier/graph-flow

πŸ”€ Flow visualization in graphs using Ford Fulkerson algorithm
https://github.com/simon-gardier/graph-flow

data-science graph-algorithms math0499 networkx python

Last synced: over 1 year ago
JSON representation

πŸ”€ Flow visualization in graphs using Ford Fulkerson algorithm

Awesome Lists containing this project

README

          

# πŸ”€ Ford-Fulkerson algorithm
![Release](https://img.shields.io/badge/Release-v1.0-blueviolet?style=for-the-badge)
![Language](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)

Python project developped for the graph theory course (MATH0499) given by Pr. Rigo, ULiège.

The final mark for this project is 19/20.


Flow example

The Ford-Fulkerson algorithm is a graph algorithm used to determine the maximum flow from a source node to a sink node. It can also be used to calculate if a minimum flow can flow through an entire network.

Using the -g option (see [Examples](#examples)), you can visualize the flow in the graph.
The lighter the color of an edge, the more saturated it is.

## Summary
1. [Required Modules](#required-modules)
2. [Project structure](#project-structure)
3. [Examples](#examples)
4. [Technical Specifics](#technical-specifics)
5. [Credits](#credits)

## Required modules
- NetworkX [https://pypi.org/project/networkx/](https://pypi.org/project/networkx/)
- Matplotlib
- Pylab

## Project structure
- ./
- main.py: Main script
- ford_fulkerson.py: Script containing the Ford-Fulkerson algorithm and pre-processing functions for loading files into Graph() objects
- display.py: Script for displaying graphs via matplotlib
- utils.py: Script for creating random graphs of any size

## Examples
1. **Finding the maximum flow from s to t in an existing file**
```console
python3 main.py -i filename.txt -s s -t t
```

2. **Finding the maximum flow from s to t in an existing file and displaying the residual graph in a window**
```console
python3 main.py -i filename.txt -s s -t t -g
```

3. **Finding the maximum flow from multiple sources to t in an existing file**
```console
python3 main.py -i filename.txt -s "s_1 s_2 s_3 s_n" -t t
```

4. **Finding the maximum flow from multiple sources to multiple sinks in an existing file**
```console
python3 main.py -i filename.txt -s "s_1 s_2 s_3 ... s_n" -t "t_1 t_2 ... t_k"
```

5. **Finding the maximum flow from s to t in a randomly generated file with n vertices**
```console
python3 main.py -r n -s s -t t
```

## Technical specifics
- Randomly generated graphs are systematically stored in ./example_random_graph.txt
- Graphs are stored in Edge List files (see [NetworkX Edge List documentation](https://networkx.org/documentation/stable/reference/readwrite/edgelist.html))

## Credits
- [Simon Gardier](https://github.com/simon-gardier) (Co-author)
- Camille Trinh (Co-author)