You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
More Network Flow Algorithms (migrated from Trac #558) #550
To follow up on this project, I made a quick speed test on the push-relabel algorithms that have been developed last summer. Since there are three of them, it would be better to only include the fastest one. The results of the test show that all push-relabel algorithms are slower than the current implementation of Ford-Fulkerson.
A typical run looks like
'''
$ python compare_relabel.py
nx.vanilla_push_relabel_maxflow 2.246 s
nx.relabel_to_front_maxflow 16.466 s
nx.highest_label_maxflow 69.296 s
nx.ford_fulkerson 0.384 s
'''
Without the random graph test, then the difference is smaller
'''
$ python compare_relabel.py
nx.vanilla_push_relabel_maxflow 0.888 s
nx.relabel_to_front_maxflow 6.250 s
nx.highest_label_maxflow 0.763 s
nx.ford_fulkerson 0.317 s
$ python3 compare_relabel.py
nx.vanilla_push_relabel_maxflow 1.178 s
nx.relabel_to_front_maxflow 5.895 s
nx.highest_label_maxflow 0.909 s
nx.ford_fulkerson 0.420 s
'''
Making the instance of the pyramid graph bigger eventually shows the power of the push-relabel method (with a pyramid graph of 25 layers):
'''
$python compare_relabel.py
nx.vanilla_push_relabel_maxflow 2.713 s
nx.relabel_to_front_maxflow 29.800 s
nx.highest_label_maxflow 1.542 s
nx.ford_fulkerson 1.826 s
'''
It seems the so called ''vanilla'' version has the best performance overall. I'll try and see if there are any speed improvements that can make it faster and then I'll push it to the main repository. The "highest label" has inconsistent performance and the "relabel to front" is clearly too slow.
Activity
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @hagberg, 2011-05-25
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @hagberg, 2011-05-25
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @hagberg, 2011-06-24
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @loicseguin, 2012-03-04
To follow up on this project, I made a quick speed test on the push-relabel algorithms that have been developed last summer. Since there are three of them, it would be better to only include the fastest one. The results of the test show that all push-relabel algorithms are slower than the current implementation of Ford-Fulkerson.
A typical run looks like
'''
$ python compare_relabel.py
nx.vanilla_push_relabel_maxflow 2.246 s
nx.relabel_to_front_maxflow 16.466 s
nx.highest_label_maxflow 69.296 s
nx.ford_fulkerson 0.384 s
'''
Without the random graph test, then the difference is smaller
'''
$ python compare_relabel.py
nx.vanilla_push_relabel_maxflow 0.888 s
nx.relabel_to_front_maxflow 6.250 s
nx.highest_label_maxflow 0.763 s
nx.ford_fulkerson 0.317 s
$ python3 compare_relabel.py
nx.vanilla_push_relabel_maxflow 1.178 s
nx.relabel_to_front_maxflow 5.895 s
nx.highest_label_maxflow 0.909 s
nx.ford_fulkerson 0.420 s
'''
Making the instance of the pyramid graph bigger eventually shows the power of the push-relabel method (with a pyramid graph of 25 layers):
'''
$python compare_relabel.py
nx.vanilla_push_relabel_maxflow 2.713 s
nx.relabel_to_front_maxflow 29.800 s
nx.highest_label_maxflow 1.542 s
nx.ford_fulkerson 1.826 s
'''
It seems the so called ''vanilla'' version has the best performance overall. I'll try and see if there are any speed improvements that can make it faster and then I'll push it to the main repository. The "highest label" has inconsistent performance and the "relabel to front" is clearly too slow.
Angga's code merged with the most recent NetworkX repository can be found at https://github.com/loicseguin/networkx.
networkx-trac commentedon Jul 20, 2012
Attachment in Trac by @loicseguin, 2012-03-04: compare_relabel.py