From ba34c5ef286be490308719335f1d7742189b8a73 Mon Sep 17 00:00:00 2001 From: Mahsa Date: Sat, 5 Feb 2022 19:05:00 +0330 Subject: [PATCH] highest-level push relabel this algorithm is efficient push relabel algorithm and in selection step selects highest-level node to see .. complexity of this algorithm is O(n2 radical m) and its better than O(n2m) --- Push-Relabel Algorithm.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Push-Relabel Algorithm.py b/Push-Relabel Algorithm.py index 3084963..081ef41 100644 --- a/Push-Relabel Algorithm.py +++ b/Push-Relabel Algorithm.py @@ -47,8 +47,15 @@ def discharge(u): push(s, v) p = 0 - while p < len(nodelist): - u = nodelist[p] + while p < len(nodelist): #selection + u=0 + heights=copy.deepcopy(height[1:n-1]) #find highest height + heights.sort() + for d in range(1,len(height)-1): + if height[d]==heights[-1]: + u = nodelist[d-1] + break + old_height = height[u] discharge(u) if height[u] > old_height: